Click to See Complete Forum and Search --> : Need Javascript!
Lt. RaZieL
01-19-2003, 05:04 PM
Hi!
I (badly) need a javascript that detects the screen resolution (800*600 or 1024*768) and after a specified amount of time redirects the user to one of two pages (i have a welcome site and i want the users to be redirected to one of two sites after 5 seconds). I would really apreciate if someone could mail me a script that can do that.
Benny from Sweden
Here you go...
<script type="text/javascript">
if (screen.width <= 800) // if less than or equal to 800x600
{
setTimeout("window.location.replace("800.htm")",5000);
}
else //everything else
{
setTimeout("window.location.replace("1024.htm")",5000);
}
</script>
Lt. RaZieL
01-20-2003, 05:53 AM
I can't get it to work. Where do i paste it?
Charles
01-20-2003, 06:01 AM
Pyro made two mistakes. The first, understandable one was to forget to use two different types of quote mark. The second, inexcusable one was to neglect the fact that one in ten users do not use JavaScript. Put this script in your document's body where you want the "Continue" link to appear for those users.
<script type="text/javascript">
if (screen.width <= 800) // if less than or equal to 800x600
{
setTimeout('window.location.replace("800.htm")',5000);
}
else //everything else
{
setTimeout('window.location.replace("1024.htm")',5000);
}
</script>
<noscript><p><a href="aFarFarBetterPage.html">Continue</a></p></noscript>
First of all, thanks for noticing my quotes error... :D
Origianlly posted by Charles
The second, inexcusable one was to neglect the fact that one in ten users do not use JavaScript.This wasn't meant to be a full page. He asked for a script to redirect users based on resolution, so I gave it to him. I certainly wouldn't consider that an error... :(
Charles
01-20-2003, 12:57 PM
Originally posted by pyro
This wasn't meant to be a full page. He asked for a script to redirect users based on resolution, so I gave it to him. I certainly wouldn't consider that an error... :( Perhaps not an error but something far worse, a grievous sin.
Originally posted by Charles
Perhaps not an error but something far worse, a grievous sin. Did you even read my last post?? I specifically said that this wasn't meant to be the complete page, simply the JavaScript necessary to perform the funtion that he asked for.
Originally posted by pyro
This wasn't meant to be a full page.
Charles
01-20-2003, 01:22 PM
Yes, it was a sin of omission rather than of commission but no less injurious to Lt.RaZieL's audience or your own soul than had it been one of commission.
Originally posted by Charles
Yes, it was a sin of omission rather than of commission but no less injurious to Lt.RaZieL's audience or your own soul than had it been one of commission. Oh my gosh...You have got to be kidding me...
Charles
01-20-2003, 02:42 PM
Originally posted by pyro
Oh my gosh...You have got to be kidding me... Well, perhaps just a little.