Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the position of an element

Status
Not open for further replies.

fox12

Programmer
Joined
Jan 18, 2005
Messages
62
Location
US
I have a <span id="posid">HERE</span> in a html page. Is there a way to find the x, y coordinates? I'd like to scroll the window to that element if it is embedded in a large page and is out of the visible range.

I need its position because I built a key word search function. If a word matches the pattern, the window will move to that position where the element is located. In the whole page, there is only one <span id="posid"></span>.

It is appreciated much if you could offer any help.

Fox12
 
If you're using IE only, you can use the scrollIntoView method to scroll the span into view:


Regarding finding the X and Y coordinates - I know this has been covered many times before... Try using the search feature to find one of many posts about this.

Hope this helps,
Dan
 
Thanks so much, Dan. It works, and starting from there, I've solved all my problems.

Fox12
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top