PDA

View Full Version : New windows not resizing....


mckinks
11-30-2002, 03:44 PM
I'm trying to get the popup windows to open in the same window but automatically resize. I thought that setting both windows dimensions that it would work, but the second window always opens in the dimensions of the first. Can anyone tell me what I'm doing wrong? I'm pretty new to javascript, so knowing me it's probably the simplest thing. :rolleyes:


<SCRIPT language=JavaScript>
function WindowOpen1()
{
window.open('/homepage/ogllad1.htm', 'Window2', 'toolbar=no, menubar=no,resizable=no,height=456,width=674');
}
function WindowOpen2()
{
window.open('/homepage/ogllad2.htm', 'Window2', 'toolbar=no, menubar=no,resizable=no,height=496,width=674');
}
</script>


and at the links I have this:

<a onClick="WindowOpen1();return false"
href="/homepage/ogllad1.htm">


<a onClick="WindowOpen2();return false"
href="/homepage/ogllad2.htm">

here it is as it appears on my site:http://lightningbrigade.freewebsitehosting.com/homepage/report.htm I am refering to the "CLICK HERE FOR MORE INFO" links. Thanks in advance.

bacterozoid
11-30-2002, 03:58 PM
Well..I'm not quite sure how to avert this, but if you have either of the windows open, then the next one that you open will maintain that size. You have to close one window first if you want the other window to be the right size.

brothercake
11-30-2002, 04:10 PM
You haven't specifically set two window objects - in fact you've given both windows the same name; the browser will regard the second window as the same object, and open the link in the window object which already exists (if it does already exist).

What you have to do is create two objects:

function WindowOpen1()
{
var Window1 = window.open('/homepage/ogllad1.htm', 'Window1', 'toolbar=no, menubar=no,resizable=no,height=456,width=674');
}
function WindowOpen2()
{
var Window2 = window.open('/homepage/ogllad2.htm', 'Window2', 'toolbar=no, menubar=no,resizable=no,height=496,width=674');
}



In fact you could reduce this further with a generalised function:

var Windows = new Array;

function WindowOpen(wNum)
{
Windows[wNum] = open('/homepage/ogllad1.htm', 'Window'+wNum, 'toolbar=no, menubar=no,resizable=no,height=456,width=674');
}

glenngv
12-02-2002, 10:44 AM
function WindowOpen(url,target,w,h)
{
win = window.open(url, target, 'toolbar=no, menubar=no,resizable=no,height='+h+',width='+w);
win.resizeTo(w,h);
}

then call it like this:

<a onClick="WindowOpen(this.href,this.target,674,456);return false"
href="/homepage/ogllad1.htm" target="Window2">

<a onClick="WindowOpen(this.href,this.target,674,496);return false"
href="/homepage/ogllad2.htm" target="Window2">