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 to the CF scene
    Join Date
    Aug 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selecting Stylesheet On Screen Resolution

    I need a piece of script that will select style800.css if the screen resolution is 800x600 or below, and style1024.css if the screen resolution is 1024x768 or above.

    Can anyone help? I've been looking for ages.

    Thanks.

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script type="text/javascript">if(screen.width>800){document.write('<link rel="stylesheet" type="text/css" href="style1024.css"  />');}else{document.write('<link rel="stylesheet" type="text/css" href="style800.css"  />');}</script>

    -james
    Last edited by jamescover; 08-29-2004 at 07:00 PM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Screen resolution has little to do with the size of the browser window your site is displayed in...
    Provide two style-sheets (one default, another alternative) and let user decide which one they want.
    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"


  •  

    Posting Permissions

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