PDA

View Full Version : Screen Resolution Redirect and Pop-Ups


realbeginner
06-12-2002, 01:57 AM
Hi all,

I have the following code which redirects a page based on the screen resolution. I want the link to open in a new window and hide the address line in the browser. Can anyone help me.

function redirectPage()
{
var url640x480 = "HomePage800.htm";
var url800x600 = "HomePage800.htm";
var url1024x768 = "HomePage1024.htm";
if ((screen.Width == 640) && (screen.height == 480))
window.location.href= url640x480;
if ((screen.Width == 800) && (screen.height == 600))
window.location.href= url800x600;
else if ((screen.Width == 1024) && (screen.height == 768))
window.location.href= url1024x768;
else
window.location.href= url1024x768;
}

<a href=#><img src="Images/ProductTitle.gif" width="152" onClick="redirectPage()" height="35" border="0"></a>

Thanking you in advance.

Jon Hanlon
06-12-2002, 05:58 PM
function redirectPage() {
var url640x480 = "HomePage800.htm";
var url800x600 = "HomePage800.htm";
var url1024x768 = "HomePage1024.htm";
var newPage = url640x480;
if (screen.Width >= 800) newPage = url800x600;
if (screen.Width >= 1024) newPage = url1024x768;
window.open(newPage,"newWin","location=no")
}

realbeginner
06-13-2002, 02:00 AM
Thanks for the help.

This works.

If I want to specify the status bar, window size etc do I do that after the location="no"?

Jon Hanlon
06-13-2002, 02:03 AM
window.open(newPage,"newWin","location=no,status=yes,width=500,height=400")

realbeginner
06-13-2002, 02:16 AM
Thanks Jon,

Got it right

function redirectPage() {
var url640x480 = "HomePage800.htm";
var url800x600 = "HomePage800.htm";
var url1024x768 = "HomePage1024.htm";
var newPage = url640x480;
if (screen.Width >= 800) newPage = url800x600;
if (screen.Width >= 1024) newPage = url1024x768;
window.open(newPage,'newWin','location=no,toolbar=no,status=yes,resizable=no,menubar=yes,scrollbars= yes,width=850,height=620')
}

My last question is how do you specify the location on the screen where the page opens? I want it in the middle obviously.

Thanks alot.

Jon Hanlon
06-13-2002, 07:15 PM
left=screen.availWidth/3, top=screen.availHeight/3

realbeginner
06-14-2002, 05:09 AM
Hi Jon and All

I now have the following function:

function redirectPage2() {
var url640x480 = "HomePage800.htm";
var url800x600 = "HomePage800.htm";
var url1024x768 = "HomePage1024.htm";
var newPage = url640x480;
if (screen.Width >= 800) newPage = url800x600;
if (screen.Width >= 1024) newPage = url1024x768;
window.open(newPage,'newWin','location=no,toolbar=no,status=yes,resizable=no,menubar=yes,scrollbars= yes,width=850,height=620,left=screen.Width/3,top=screen.height/3')
}

The new window that opens opens in the top corner instead of the middle of the page.
How do I open it the middle of the screen?

Thanks