[Project_owners] getting the visible range of an html doc?

Shawn Betts sabetts at vcn.bc.ca
Wed Oct 20 04:20:09 EDT 2004

Shawn Betts <sabetts at vcn.bc.ca> writes:

> Hi folks,
> Is there a way to get a DomRange (for instance) of the visible portion
> of a web page?
> I'd like to write a function that highlights a string match on a webpage, but only
> in the currently visible area.
> nsiSelectionController has checkVisibility so I as a last resort I
> could walk each node in the document to get a range. But..I'm hoping
> there's an existing way.

After thinking about this further, I don't think it'd be possible to
get a singe range for the visible region of a doc. 

So, instead I could perform the search and get the rectangle
containing startContainer endContainer and see if either is visible
(compare rect coords with the window's scrollX, scrollY). I KNOW a
node's bounding rectangle can be found because the DOM Inspector
flashes it. But it seems the inspector uses it's own flasher module
that's written in C++.

Is there a way to get this bounding rectangle from XUL? Or will I
have to hack C++ to do it?



More information about the Project_owners mailing list