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.javascripttoolbox.com/lib/objectposition/source/position.js"></script><script type="text/javascript">window.onload = function() { var pos=Position.get(document.getElementById('mainDiv' )); Position.set(document.getElementById('marker1'),po s); var pos=Position.get(document.getElementById('idText') ); Position.set(document.getElementById('marker2'),po s);}</script><style>#idText { border:1px red solid ; }#mainDiv { position:relative ; top:115px ; margin-left:150px; border:1pxsolid blue; margin-right:0px ;}.marker {position:absolute;width:10px;height:10px;border:1 px 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>--Matt Krusehttp://www.JavascriptToolbox.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.javascripttoolbox.com/lib/objectposition/source/position.js">
</script>
<script type="text/javascript">
window.onload = function() { var
pos=Position.get(document.getElementById('mainDiv' ));
Position.set(document.getElementById('marker1'),po s);
var pos=Position.get(document.getElementById('idText') );
Position.set(document.getElementById('marker2'),po s);
}
</script>
<style>
#idText { border:1px red solid ; }
#mainDiv {
position:relative ;
top:115px ;
margin-left:150px;
border:1pxsolid blue;
margin-right:0px ;
}
..marker {
position:absolute;
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.javascript FAQ -
http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/