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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    adjusting for different resolutions....

    I was just wondering if there was a way to detect the screen resolution someone is using and loading a different CSS file depending on the res they have....is that possible?? the way I am designing things i need to do this for it to work. its the only way!!

    thanks....

    brent

  • #2
    New Coder
    Join Date
    Jul 2002
    Location
    UK
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi brent,

    best thing to do is to use a redirect html file to call a specific html file depending on the screen resolution.
    insert this code into your index.html file.

    but dont forget to change the hyperlinks to your own

    <script language="JavaScript1.2">
    <!--

    if (screen.width==800||screen.height==600) //if 800x600
    window.location.replace("http://yourdomain.com/index800.html")

    else if (screen.width==640||screen.height==480) //if 640x480
    window.location.replace("http://yourdomain.com/index640.html")

    else if (screen.width==1024||screen.height==768) //if 1024x768
    window.location.replace("http://yourdomain.com/index1024.html")

    else //if all else
    window.location.replace("http://yourdomain.com/index800.html")

    //-->
    </script>


    now when you have done this, each different html file you specified in the script, place the desired css file required in them.

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks man, i will try that out!!!

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    TEXAS . . . 'nuf said
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, andrewsheldon98's solution will require you to create web pages for every single browser resolution...or at least as many as you want to make. This will, in turn, will cause you to update each page for each resolution when you make a single update. That could quickly become a pain in the arse!

    You said you wanted separate CSS files for various resolutions. I believe the following will take care of you. Now, you'll only need multiple CSS files. This particular example only designates between <=800px and >800px. If you need anything further, I'm fairly certain you'll easily be able to adjust the code accordingly.

    Change the colored portions as needed:

    <head>

    <script>
    <!--
    if (screen.width <= 800 || screen.height <= 600) {
    document.write("<link rel='STYLESHEET' type='text/css' href='css-red-800-or-less.css' title='css800pxorless'>");
    }
    else if (screen.width > 800 || screen.height > 600) {
    document.write("<link rel='STYLESHEET' type='text/css' href='css-blue-above-800.css' title='cssforabove800px'>");
    }
    -->
    </script>

    </head>

    Any questions?
    Gordo
    "In the End, we will remember not the words of our enemies, but the silence of our friends."
    - Martin Luther King Jr. (1929-1968)

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Or better yet, create a fluid layout that will work with any resolution (including WebTV hehe)
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    You can make all the pages you want...but here's an easy way to center page regardless of resolution:

    <body>
    <table width="100%" height="100%">
    <tr><td align="center" valign="middle">

    your html code


    </td></tr>
    </table>
    </body>

    The height attribute is for older NS browsers.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #7
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it would be nice to make it all fluid, but i am using some absolute positioning for things and that obviously changes where things are placed when the resolution is changed......i seem to have it worked out now.....except my friend is using IE 5.5 on a mac, and he said the absolute positioning isnt working on there.....thats a whole new problem. argh.


  •  

    Posting Permissions

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