|
-
Jul 27th, 2005, 03:46 PM
#1
Thread Starter
Junior Member
Iframe coordinate problem
Need a little help if any anyone can.
Im trying to get the mouse coordinates in relation to the window when I click on any image. I can get the correct coordinates of the image in div1 but I cant get the correct coordinates in the image that is in the iframe. I tried firedobj.parentNode but that seems to be the body of the iframe and I cant go any higher to account for the offset of the iframe itself.
main.htm
<html>
<script language="JavaScript1.2">
<!--
var ie=document.all
var ns6=document.getElementById&&!document.all
function show(event) {
var firedobj=ns6? event.target : event.srcElement
el= document.getElementById(firedobj.id)
while (el.parentNode.nodeName!="BODY")
{
el = el.parentNode
tempx=tempx + el.offsetLeft
tempy=tempy + el.offsetTop
}
alert(tempx + "," + tempy)
}
//-->
<body>
<DIV id="div1" style="left:203px;width:240px;border:2px solid #FF0000;">
<img id="imagez" border="0" src="images/1.jpg" width="100" height="100" onmousedown="show(event);">
<iframe id="I2" src="frame2.htm" width="240" height="150" border="0" frameborder="0" style="background-color: #FFFFFF"></iframe>
<iframe id="I3" src="frame3.htm" width="240" height="150" border="0" frameborder="0" style="background-color: #FFFFFF"></iframe>
</DIV>
</body>
</html>
frame2.htm:
<html>
<body>
<img id="image1" border="0" src="images/1.jpg" width="100" height="100" onmousedown="top.show(event);">
img id="image2" border="0" src="images/2.jpg" width="100" height="100" onmousedown="top.show(event);">
img id="image3" border="0" src="images/3.jpg" width="100" height="100" onmousedown="top.show(event);">
</body>
</html>
any help is appriecated!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|