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 6 of 6
  1. #1
    New Coder
    Join Date
    Sep 2003
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Generic screen resolution redirect

    I have the following screen resolution redirection script:

    var correctwidth=1024
    var correctheight=768

    if (screen.width<correctwidth||screen.height<correctheight)
    location.href="index8.html";

    The above works just fine, the only thing I don't like about it is that it's not generic which does not allow me to place it in a js file and point every page at it. I would like to enhance the above code to make it generic. To help the process my 800x600 pages are named the same as the 1024x768 pages but with an 8 added on. So, in the above example my 1024x768 home page file name is index.html, and the corresponding 800x600 home page is named index8.html.

    What I need the script to do is redirect the user to a page with a name that matches that which was actually requested but with an 8 added at the back (ie index8.html if index.html was requested). If it makes things easier I could differentiate the files using extension type (eg .html for 1024x768 pages and .htm for 800x600 pages), in which case if index.html was requested the user would be redirected to index.htm.

    Could someone please help me make code at the top generic using one of the methods described above.

    Thanks

    icradz

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And what would your script do when I visit it using 1280x1024?

    The fallicy of fixed size web pages is still going to trip you up and oh yeah, while my monitor is 1280x1024, I run the web page at a smaller size (not full-screen). Oh wait again! I like your page so much that I want to check up on it when I'm not at my computer, I'll use my PDA but it has a 300x200 screen on it.

    You can't please everyone all the time but you really, really need to look at if or how you can make your web page work ok regardless of the user's resolution just to save yourself the work of creating endless copies of the page to match the various screen resolutions users will hit you with.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New Coder
    Join Date
    Sep 2003
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Roy,

    Thanks for the feedback. With your higher resolution you'll simply get the 1024x768 version. There is no way I would attempt to cover all the resolutions uisng this method. The most popular ATM (1024x768 and 800x600) will do. I've read up on liquid page design and whilst it sounds really warm and fluffy I think it's a complete falasy that you can get your site looking exactly the way you want in all the resolutions!

    So, back to the question at hand, can the script I posted earlier be made generic?

    Cheers

    icradz

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I think I got your point. You need to find the path name of the page, and change it when redirect. Use the

    self.location.pathname

    reference to get the pathname of your page. The result is a string which you can manipulate using usual string methods, for instance split()....

    Is it this information enough to you?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by icradz
    I've read up on liquid page design and whilst it sounds really warm and fluffy I think it's a complete falasy that you can get your site looking exactly the way you want in all the resolutions!
    Nobody's saying that. The real fallacy is that you can get your site looking exactly the way you want in *any* resolution - it will *never* look to others how it looks to you, and it doesn't have to - a well made site is not one that looks the same to all, it's one that is useable by all regardless of the device used to access it.

    Nonetheless, if your design benchmarks are 800x600 to 1024x768 you shouldn't have trouble making a design fluid within those constraints.

    It's up to you of course, but your current path will cause you nothing but grief, and eventually you'll abandon it. May as well save yourself the pain.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    There is no way I would attempt to cover all the resolutions uisng this method.
    Yes, but you actually can cover all the resolution using, as Roy and brothercake well said, liquid design techniques (% dimensions, relative position, using screen.availWidth and screen.availHeight and so on....)...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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