SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: css selector

Hybrid View

  1. #1
    SitePoint Enthusiast fatlip007's Avatar
    Join Date
    Sep 2003
    Location
    Essex, England
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    css selector

    I'm trying to write a piece of javascript to select a particular css file based on the browsers screen resolution. At the moment I've got this:

    Code:
    var ScrnSize;
    
    ScrnSize = screen.width + "x" + screen.height;
      
    switch(ScrnSize) {
    
    case "800x600":   
    	document.write('<link rel="stylesheet" type="text/css" href="style/lowres.css" />');
    default:          
    	document.write('<link rel="stylesheet" type="text/css" href="style/hires.css" />');
    }
    But it always seems to go to the default value no matter what. I'm a newb at javascript, so any help is appreciated

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here, read this. Pay particular attention to the part about the break statement.
    ::: certified wild guess :::

  3. #3
    SitePoint Enthusiast fatlip007's Avatar
    Join Date
    Sep 2003
    Location
    Essex, England
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how did i miss that! Thanks alot


Bookmarks

Posting Permissions

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