Is HTML text string within current scrolling visible area of browser window?
Jim Ault
jimaultwins at yahoo.com
Sun Mar 27 09:29:52 EDT 2011
On Mar 27, 2011, at 3:55 AM, Keith Clarke wrote:
> Hi folks,
> Can anyone help me with the correct terms to seed my Google search?
>
> I'm trying to discover whether it's possible to check
> programmatically (maybe with Javascript, Jquery, etc.) whether a
> specific element on a web page (that is readable from the page
> HTML), such as a specific div, tag or string, is currently within
> the visible rendered page area of a browser window with a (vertical)
> scroll bar.
>
> Otherwise, if it's a specific page - with a known layout and
> therefore calculable coordinates for the element to find - is it
> possible to know how the browser window's current size and scroll
> offset relate to the 'underlying' page?
This calculation is the same for all browsers, except that
IE does not follow the same metrics calculations, and, of course, it
is different with in versions of IE.
offsetLeft & offsetTop < HTML DOM
http://www.w3schools.com/jsref/dom_obj_all.asp
pageX & pageY < window scroll
http://www.w3schools.com/jsref/prop_win_pagexoffset.asp
Also, 'position' is the keyword for CSS
JQuery
go to http://visualjquery.com/ (which is a very cool page by Remy
Sharp)
Enter the letter 'O' into the filter box and click on the 'offset'
button that appears.
You will see an example calculation.
Of course, 'location' refers to the URL of the content, not page layout.
I just saw a javascript routine that does the calculation based on
browser-detection a couple days ago, but can't remember exactly where
it is. If you need more info, I could try to find it. Let me know.
Jim Ault
Las Vegas
More information about the use-livecode
mailing list