Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript Redirect Has Problems

    I'm working on a redirect script, where the script sends you to a page based on your resolution. I have tried everything I have found on the internet from:

    window.location
    window.location.href
    document.location
    document.location.href
    location.replace
    self.location

    In any case, I was hoping that someone could show me the problem.

    Code:
    if ((screen.width == 640) && (screen.height == 480))
    	alert("Your resolution must be at least 800x600");
    else if ((screen.width == 800) && (screen.height == 600))
    	document.location.href = "theater800x600.html";
    else if ((screen.width == 1024) && (screen.height == 768))
    	document.location.href = "theater1024x768.html";
    else if ((screen.width == 1152) && (screen.height == 864))
    	document.location.href = "theater1152x864.html";
    else if ((screen.width == 1280)) && (screen.height == 720))
    	document.location.href = "theater1280x720.html";
    else if ((screen.width == 1280) && (screen.height == 768))
    	document.location.href = "theater1280x768.html";
    else if ((screen.width == 1280) && (screen.height == 960))
    	document.location.href = "theater1280x960.html";
    else if ((screen.width == 1280) && (screen.height == 1024))
    	document.location.href = "theater1280x1024.html";
    else if ((screen.width == 1360) && (screen.height == 768))
    	document.location.href = "theater1360x768";
    else if ((screen.width == 1600) && (screen.height == 900))
    	document.location.href = "theater1600x900.html";
    else if ((screen.width == 1600) && (screen.height == 1024))
    	document.location.href = "theater1600x1024.html";
    else if ((screen.width == 1600) && (screen.height == 1200))
    	document.location.href = "theater1600x1200.html";
    else if ((screen.width == 1920) && (screen.height == 1080))
    	document.location.href = "theater1920x1080.html";
    else if ((screen.width == 1920) && (screen.height == 1200))
    	document.location.href = "theater1920x1200.html";
    else if ((screen.width == 1920) && (screen.height == 1440))
    	document.location.href = "theater1920x1440.html";
    else if ((screen.width == 2048) && (screen.height == 1534))
    	document.location.href = "theater2048x1534.html";
    else alert("The maximum size that this page supports is 2048x1534.  Please adjust your resolution.");
    I have the <SCRIPT></SCRIPT> and all that, but this is the main part.

    Cheers.

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Posts
    679
    Thanks
    0
    Thanked 16 Times in 15 Posts
    You have an extra ) in this line :
    Code:
    else if ((screen.width == 1280)) && (screen.height == 720))
    	document.location.href = "theater1280x720.html";
    I would use location.replace or reload, otherwise when someone hits their back button on the theater page they will be in a loop - the redirect page will send them back to the theater page.

    /Bob

  • #3
    New Coder
    Join Date
    Apr 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help.

    Cheers.
    -Alan


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •