Web Analytics Made Easy -
StatCounter adjusting for different resolutions.... - CodingForum

Announcement

Collapse
No announcement yet.

adjusting for different resolutions....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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.

    Comment


    • #3
      thanks man, i will try that out!!!

      Comment


      • #4
        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)

        Comment


        • #5
          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"

          Comment


          • #6
            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( ! )">

            Comment


            • #7
              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.

              Comment

              Working...
              X