Actually, what you mean then is to position the DHTML window relative to some other element on the page (ie: the table). Right now the DHTML window positions itself absolutely on the page, so depending on the screen resolution, the same coordinates of 100, 300 for example will point to different things on the page.
One way to position the DHTML window so it's relative to another element on the page is to first calculate the coordinates of this other element relative to the upper left corner of the page, and use the script's moveTo() function to move to those coordinates. The below example moves a DHTML window instance so it's positioned right on top of a paragraph:
Code:
<p id="test">
This is some textThis is some textThis is some textThis is some textThis is some textThis is some text
</p>
<!-- 1) DHTML Window Example 1: -->
<script type="text/javascript">
var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://images.google.com/", "#1: Google Web site", "width=590px,height=350px,resize=1,scrolling=1,center=1", "recal")
dhtmlwindow.getposOffset=function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}
var anchorelement=document.getElementById("test")
googlewin.moveTo(dhtmlwindow.getposOffset(anchorelement, "left"), dhtmlwindow.getposOffset(anchorelement, "top"))
</script>
Here the DHTML window is positioned relative to/ on top of the paragraph with id="test". The code in red is the function you want to add to your page, then use it according to the lines that follow.
Bookmarks