PDA

View Full Version : Help with resolution detection!


Netmechanik
05-14-2003, 12:01 AM
I have written this code but just cant get the thing to work. I want to create popup windows that display in different places according to the viewers resolution. I need help please! If i change the function to document.write() it displays the correct values, so i take it there is no problem there, but when i add the function newWindow it diplays at width=0 height=0 no matter what res i run at


********************************************
The code:

var width = screen.width;

var res =(((!(640-width))*1)+((!(800-width))*2)+((!(1024-width))*3)+((!(1152-width))*4)+((!(1280-width))*5)+((!(1600-width))*6));

if(!(res)) res = 1;


// 640x480 code goes here

if (res=='1') {

function newWindow(newContent)
{
winContent = window.open(newContent, 'nextWin', 'left=,top=0,width=625,height=460,toolbar=no,scrollbars=no,resizable=yes')

winContent.focus()
}


}


// 800x600 code goes here

if (res=='2') {

function newWindow(newContent)
{
winContent = window.open(newContent, 'nextWin', 'left=88,top=50,width=625,height=460,toolbar=no,scrollbars=no,resizable=yes')

winContent.focus()
}


}


// 1024x768 code goes here

if (res=='3') {

function newWindow(newContent)
{
winContent = window.open(newContent, 'nextWin', 'left=200,top=120,width=625,height=460,toolbar=no,scrollbars=no,resizable=yes')

winContent.focus()
}

}


// 1152 & 1280 & 1600 code goes here

if (res=='4' || res=='5' || res=='6') {

function newWindow(newContent)
{
winContent = window.open(newContent, 'nextWin', 'left=300,top=150,width=625,height=460,toolbar=no,scrollbars=no,resizable=yes')

winContent.focus()
}

}



//all other resolutions

if (res!='1' && res!='2' && res!='3' && res!='4' && res!='5' && res!='6') {

function newWindow(newContent)
{
winContent = window.open(newContent, 'nextWin', 'left=0,top=0,width=625,height=460,toolbar=no,scrollbars=no,resizable=yes')

winContent.focus()
}


}

******************************
I would appreciate it if anybody has any ideas

Clive

glenngv
05-14-2003, 02:56 AM
isn't the variable res an integer not a string?

function newWindow(newContent,x,y)
{
winContent = window.open(newContent, 'nextWin', 'left='+x+',top='+y+',width=625,height=460,toolbar=no,scrollbars=no,resizable=yes');
winContent.focus();
}


...
if (res==1) {
newWindow(newContent,0,0);
}
else if (res==2){
newWindow(newContent,88,50);
}
else if...

Netmechanik
05-14-2003, 08:05 AM
Thanks Glenn,

I'll give it a try today and let you know!

Clive

A1ien51
05-14-2003, 08:22 AM
did you notice 'left=,top in your first window statement??

just wondering

Netmechanik
05-14-2003, 08:28 AM
Ja I did, thanks for pointing it out though!