Matt Kruse said the following on 1/11/2007 11:49 AM:
Petra Meier wrote:
>thanks for answering, but it did not work.. try yourself
I see - it finds the mainDiv correctly, but not the div inside of it. I will
have to work on a fix to the lib to handle cases like this. Here is my test
case:
<html>
<script type="text/javascript"
src="http://www.javascriptt oolbox.com/lib/objectposition/source/position.js"></script><script type="text/javascript">win dow.onload = function() { var pos=Position.ge t(document.getE lementById('mai nDiv')); Position.set(do cument.getEleme ntById('marker1 '),pos); var pos=Position.ge t(document.getE lementById('idT ext')); Position.set(do cument.getEleme ntById('marker2 '),pos);}</script><style># idText { border:1px red solid ; }#mainDiv { position:relati ve ; top:115px ; margin-left:150px; border:1pxsolid blue; margin-right:0px ;}.marker {position:absol ute;width:10px; height:10px;bor der:1px solid black;}#marker1 { background-color:yellow; }#marker2 { background-color:blue; }</style><body><di v id="marker1" class="marker"> </div><div id="marker2" class="marker"> </div><div id="mainDiv">## ######<div id="idText">a text</div>########### #</div></body></html>--Matt Krusehttp://www.JavascriptT oolbox.comhttp://www.AjaxToolbox .com
If there were ever a case of a news agent hosing posted code that would
have to be the winner :)
For what it's worth, it seems to work properly in FF2 and O9.
Maybe this one won't get hosed:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script
src="http://www.javascriptt oolbox.com/lib/objectposition/source/position.js">
</script>
<script type="text/javascript">
window.onload = function() { var
pos=Position.ge t(document.getE lementById('mai nDiv'));
Position.set(do cument.getEleme ntById('marker1 '),pos);
var pos=Position.ge t(document.getE lementById('idT ext'));
Position.set(do cument.getEleme ntById('marker2 '),pos);
}
</script>
<style>
#idText { border:1px red solid ; }
#mainDiv {
position:relati ve ;
top:115px ;
margin-left:150px;
border:1pxsolid blue;
margin-right:0px ;
}
..marker {
position:absolu te;
width:10px;
height:10px;
border:1px solid black;
}
#marker1 {
background-color:yellow;
}
#marker2 {
background-color:blue;
}
</style>
<body>
<div id="marker1" class="marker"> </div>
<div id="marker2" class="marker"> </div>
<div id="mainDiv">## ######
<div id="idText">a text</div>
############</div>
</body>
</html>
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ -
http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/