View Full Version : DHTML Window Widget (v1.1) - Fixed Position

01-11-2008, 04:00 PM
1) Script Title: DHTML Window Widget (v1.1)

2) Script URL (on DD): http://dynamicdrive.com/dynamicindex8/dhtmlwindow/

3) Describe problem:
I need the window to always appear in the same place on the page (ie, beside a certain image) rather than relative to the window viewpoint. Can anyone help me?

01-12-2008, 12:47 AM
Are you looking for all DHTML windows to be positioned relative to a specific (single) image on the page?

01-12-2008, 02:13 AM
Yes, that's correct.

02-13-2009, 08:01 AM

have you found or is there a solution for this? I too, wish to keep the popup in a fixed position and not relative to the viewing screen

Thanks in advance

02-14-2009, 05:55 PM
There's actually a few threads on this already. Please do a search. For example, see my response here: http://www.dynamicdrive.com/forums/showthread.php?t=25050

02-14-2009, 07:54 PM
Hi ddadmin,

in your post, you provided the solution using id=test with this code:

<p id="test">
This is some textThis is some textThis is some textThis is some textThis is some textThis is some text

<!-- 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;
return totaloffset;

var anchorelement=document.getElementById("test")

googlewin.moveTo(dhtmlwindow.getposOffset(anchorelement, "left"), dhtmlwindow.getposOffset(anchorelement, "top"))


I tried it and it works great.

Can you please advice how to change the code so that it will work with the following version of popups i use:

<a href="#" onClick="divwin=dhtmlwindow.open('divbox', 'div', first_popup, 'Free spirit', 'width=620px,height=155px,left=52px,top=462px,resize=0,scrolling=0'); return false"></a><br><br>

<a href="#" onClick="divwin=dhtmlwindow.open('divbox', 'div', second_popup, 'Free spirit2', 'width=620px,height=155px,left=52px,top=462px,resize=0,scrolling=0'); return false"></a>

Thanks in advance