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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding x y position of <table> on page

Status
Not open for further replies.

RonHerman

Programmer
Jun 4, 2001
11
US
I have a series of tables, one after another, on a page. I'd like to know the y position of these tables. But the tables are not absolute positioned. So i don't know if this is possible. I've tried surrounding a table with <div id='someid'></div> and then at the end of the page using

<script>
alert( document.getElementByID('someid').style.pixelTop );
</script>

but this reports 0. Any ideas?
Thanks,
Ron S.H.
 
Oh, yes, I'm only concerned with making this work in IE.
 
offsetTop is used by Netscape. pixelTop is used by IE. But neither works in IE.
 
>> this works: alert( findme.offsetTop );

so, jeff's post is correct, yes?

-pete
 
Yes, Jeff's post is correct. THANK YOU Jeff!!
However, I was not able to get:

alert( document.getElementByID('someid').offsetTop );

to work, so I used:

alert( someid.offsetTop );

instead.

Ron

 
Ron,

does your element have id='someid' or just name='someid'?

you need to use &quot;id&quot; if you want getElementById() to work.



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Jeff,

I think he's using IE4.x which as you most likely know doesn't understand document.getElementById but understands direct references to the ID element (which I'd like to see become a standard).

Ron,

I recommend you use document.getElementById(yourID) as Jemminger rightfully pointed out so that it works in future browsers (it is a standard and as responsible developers should follow them, read more here :
This bit of code will fix the document.getElementById method so that it works with older non-standard compliant browsers. Add this to your code to make it work with older versions of IE (that don't understand document.getElementById).

if (!document.getElementById)
{
document.getElementById = function(id)
{
return document.all[id]
}
}

I hope this helps you out.

Gary Haran
==========================
 
Gary, thank you. I will use your code. I appreciate your help!
Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top