chrisparton1991
11-27-2006, 04:35 AM
Hi there pplz.
Can someone tell me why this script doesn't work? (the whole page is there as you can see :))
The script is meant to redirect the user to the appropriate site according to resolution, and - if the resolution isn't supported - redirect them to the best-fitting site.
For some reason, once i added the code to redirect you to the nearest site, the script stopped working :(.
<html>
<head>
<title>Welcome to Corrimal High School! Detecting Monitor Resolution...</title>
<link rel = "StyleSheet" href = "table.css" type = "text/css">
</head>
<body bgcolor = "#e5e5e5">
<table align = "center" width = "90%" cellpadding = 0 cellspacing = 0>
<td align = "center"><b>Please wait, detecting monitor resolution and redirecting as neccessary...</b></br></br>
<b>If a yellow bar like the one below:</br></br>
<img src = "activex.png" border = "1"></br></br>
<b>shows up, click on it, then click on "allow blocked content...". Then click yes.</b></br>
</td></tr>
</table>
<script language = "JavaScript">
<!--
//Script made by Chris Parton, feel free to use it in any way you wish!
var scrWidth=screen.width;
var scrheight=screen.height;
if ((screen.width==1024) && (screen.height==768))
{
document.write('<META HTTP-EQUIV="refresh" content="4;URL=1024x768/index.html"> ')
}
else if ((screen.width==1280) && (screen.height==960))
{
document.write('<META HTTP-EQUIV="refresh" content="4;URL=1280x960/index.html"> ')
}
else if ((screen.width==1600) && (screen.height==1200))
{
document.write('<META HTTP-EQUIV="refresh" content="4;URL=1600x1200/index.html"> ')
}
//////////////////////////////////Start of sketchy script
else if ((scrWidth >= 1024) && (scrWidth < 1280)) || ((scrHeight >= 768) && (scrHeight < 960))
{
document.write('<center></br><hr></br><b>We could not determine your resolution, you will be redirected to the page that best fits your screen. If you do not understand this, please disregard this message.</b><META HTTP-EQUIV="refresh" content="8;URL=1024x768/index.html"> ')
}
else if ((scrWidth >= 1280) && (scrWidth < 1600)) || ((scrHeight >= 960) && (scrHeight < 1200))
{
document.write('<center></br><hr></br><b>We could not determine your resolution, you will be redirected to the page that best fits your screen. If you do not understand this, please disregard this message.</b><META HTTP-EQUIV="refresh" content="8;URL=1280x960/index.html"> ')
}
else if ((scrWidth >= 1600)) || ((scrHeight >= 1200))
{
document.write('<center></br><hr></br><b>We could not determine your resolution, you will be redirected to the page that best fits your screen. If you do not understand this, please disregard this message.</b><META HTTP-EQUIV="refresh" content="8;URL=1600x1200/index.html"> ')
}
//////////////////////////////////End of sketchy script
//-->
</script>
</body>
</body>
</html>
If i get rid of the 'sketchy script', it works fine(my monitor is supported), but when i add it in, the whole thing screws up.
as you may be able to see, im only new to JavaScript, so I'm hoping it's a boneheaded mistake like a missing operator :).
Thanks heaps,
Chris
Can someone tell me why this script doesn't work? (the whole page is there as you can see :))
The script is meant to redirect the user to the appropriate site according to resolution, and - if the resolution isn't supported - redirect them to the best-fitting site.
For some reason, once i added the code to redirect you to the nearest site, the script stopped working :(.
<html>
<head>
<title>Welcome to Corrimal High School! Detecting Monitor Resolution...</title>
<link rel = "StyleSheet" href = "table.css" type = "text/css">
</head>
<body bgcolor = "#e5e5e5">
<table align = "center" width = "90%" cellpadding = 0 cellspacing = 0>
<td align = "center"><b>Please wait, detecting monitor resolution and redirecting as neccessary...</b></br></br>
<b>If a yellow bar like the one below:</br></br>
<img src = "activex.png" border = "1"></br></br>
<b>shows up, click on it, then click on "allow blocked content...". Then click yes.</b></br>
</td></tr>
</table>
<script language = "JavaScript">
<!--
//Script made by Chris Parton, feel free to use it in any way you wish!
var scrWidth=screen.width;
var scrheight=screen.height;
if ((screen.width==1024) && (screen.height==768))
{
document.write('<META HTTP-EQUIV="refresh" content="4;URL=1024x768/index.html"> ')
}
else if ((screen.width==1280) && (screen.height==960))
{
document.write('<META HTTP-EQUIV="refresh" content="4;URL=1280x960/index.html"> ')
}
else if ((screen.width==1600) && (screen.height==1200))
{
document.write('<META HTTP-EQUIV="refresh" content="4;URL=1600x1200/index.html"> ')
}
//////////////////////////////////Start of sketchy script
else if ((scrWidth >= 1024) && (scrWidth < 1280)) || ((scrHeight >= 768) && (scrHeight < 960))
{
document.write('<center></br><hr></br><b>We could not determine your resolution, you will be redirected to the page that best fits your screen. If you do not understand this, please disregard this message.</b><META HTTP-EQUIV="refresh" content="8;URL=1024x768/index.html"> ')
}
else if ((scrWidth >= 1280) && (scrWidth < 1600)) || ((scrHeight >= 960) && (scrHeight < 1200))
{
document.write('<center></br><hr></br><b>We could not determine your resolution, you will be redirected to the page that best fits your screen. If you do not understand this, please disregard this message.</b><META HTTP-EQUIV="refresh" content="8;URL=1280x960/index.html"> ')
}
else if ((scrWidth >= 1600)) || ((scrHeight >= 1200))
{
document.write('<center></br><hr></br><b>We could not determine your resolution, you will be redirected to the page that best fits your screen. If you do not understand this, please disregard this message.</b><META HTTP-EQUIV="refresh" content="8;URL=1600x1200/index.html"> ')
}
//////////////////////////////////End of sketchy script
//-->
</script>
</body>
</body>
</html>
If i get rid of the 'sketchy script', it works fine(my monitor is supported), but when i add it in, the whole thing screws up.
as you may be able to see, im only new to JavaScript, so I'm hoping it's a boneheaded mistake like a missing operator :).
Thanks heaps,
Chris