the above from another script I helped someone with to scroll some text...
http://www.experts-exchang
Main Topics
Browse All Topicsi am trying to find out a div's x location with ie
i use this code in mozilla and it works
document.getElementById('p
but in ie, it is undefined. i've been trying to use different methods like
document.getElementById('p
so a div surrounded in a few other divs i want to get the distance of this div compared to the browser window left and top
and i can't assign a style to this div, the div is placed when page loads, and i just want to get the position where it is located in ie
thanks for your time
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
the above from another script I helped someone with to scroll some text...
http://www.experts-exchang
it still doesn't work, but maybe it has to do with my application
<!-- other code before -->
<td height="400" valign="top" bgcolor="#e1eae9">
<div align="center" id="mainpicture" class="titletxt">
<div id="backpic" style="border: 1px dashed white" onClick="activate_layer('b
<img src="<?php echo $back_pic; ?>" alt="" width="<?php echo $imagewidth; ?>" height="<?php echo $imageheight; ?>" id="pic">
</div>
</div>
</td>
<!-- other code after -->
is it because i never added a interger for my style????
thanks for all your help
i made it simple, and did it so you can see how it works on firefox, but the same code doesn't work on ie6... just click on the image (linked externally, so you can load this script anywhere to test)
thanks in advance
<script type="text/javascript">
function xCoord(id)
{
object = document.getElementById(id
xc = parseInt(object.style.left
alert (xc);
object = document.getElementById(id
xc = parseInt(object.x);
alert ('firefox works '+xc);
}
</script>
<table align="center">
<tr>
<td height="400" valign="top" bgcolor="#e1eae9">
<div align="center" id="mainpicture" class="titletxt">
<div id="backpic" style="border: 1px dashed white" onClick="xCoord('pic');">
<img src="http://www.pentegroup
</div>
</div>
</td>
</tr>
</table>
give this a try:
<html>
<head>
<script type="text/javascript">
function findPos(id)
{
var obj = document.getElementById(id
var curleft = curtop = 0;
if (obj.offsetParent)
{
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent)
{
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
alert('left: ' + curleft + ' top: ' + curtop);
}
</script>
</head>
<body>
<table align="center">
<tr>
<td height="400" valign="top" bgcolor="#e1eae9">
<div align="center" id="mainpicture" class="titletxt">
<div id="backpic" style="border: 1px dashed white" onClick="findPos('pic');">
<img src="http://www.pentegroup
</div>
</div>
</td>
</tr>
</table>
</body>
</html>
Business Accounts
Answer for Membership
by: jasonsbytesPosted on 2007-06-29 at 12:43:09ID: 19392997
Try: ); );
function xCoord(id)
{
object = document.getElementById(id
xc = parseInt(object.style.left
return xc;
}