PDA

View Full Version : help with positioning



Perplexed
02-14-2007, 02:05 PM
1) DHTML Window:

2) http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow.htm

3) Describe problem: Script works great but how do I get the popup
window to popup in a specific location instead of in the upper left hand
corner. I am using it to popup answers to FAQs and would like it to popup under the FAQ that is clicked on.

Thanks for your help.

jscheuer1
02-14-2007, 03:27 PM
This is where that is determined:


function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}

Change the colored numbers. 30 from the left and 30 (two places in the above) from the top are the 'default'. You could also do this:


function loadwindow(url,width,height,wleft,wtop){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left=wleft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+wtop+"px" : iecompattest().scrollTop*1+wtop+"px"
document.getElementById("cframe").src=url
}
}

Now you can specify in the calls, ex:


<a href="javascript:loadwindow('http://www.google.com',600,400,50,100)">Geocities</a>

Perplexed
02-15-2007, 03:28 AM
It worked great.

Thanks ever so much for the help!