Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorisyjack
    • CommentTimeOct 21st 2008
     permalink
    I'm a complete javascript newbie and I know it's not exactly wise to jump into jquery as such, but I did so anyway because I needed something done fairly quickly and in a simple manner. So, forgive me if this is not the most efficient way to get this done.

    Anyway, the idea behind the script is to swap out the existing linked css file with another random one after a set amount of time.

    As such, I have the following in the head section:

    Code:

    <link href="styles/style1.css" type="text/css" rel="stylesheet" id="stylesheet" />

    <script type="text/javascript" src="scripts/jquery.js"></script>
    <script type="text/javascript">

    var interval
    $(document).ready(function() {
    interval = setInterval("getCSS()", 5000);// 5 secs between requests
    });

    function getCSS() {
    // randomize the stylesheet to be loaded
    var r = Math.floor(Math.random()*3+1);
    // set stylesheet to new stylesheet + randomized number
    $("#stylesheet").attr({href : "styles/style"+r+".css"});
    }
    </script>


    Everything works nicely in all browsers I've tested (FF, Safari, and Opera) except (of course) IE. Mainly, it swaps out the css (in this case, I'm just changing the background and some text colors for testing purposes). The problem is that only the area that has content receives an update in the background color. Anywhere else, the background remains the same as before. I'm not sure what the problem is, maybe IE renders too slowly, but if you minimize the browser, then maximize again, the background colors display correctly. The problem only shows up if the screen is in view when the css swap happens.

    The example can be viewed here: http://reviewdesigns.com/clients/csstest/.

    Anyone know a way to fix this problem? Any help is much appreciated.
    •  
      CommentAuthorkari.patila
    • CommentTimeOct 21st 2008 edited
     permalink
    Perhaps you need a width:100%, height:100% or overflow:auto on body, or possibly all of them together. I'm guessing that IE doesn't understand dimensions unless you explicitly declare them. In this case it only knows the dimensions of the h1 and p elements.
    • CommentAuthorisyjack
    • CommentTimeOct 21st 2008
     permalink
    Thanks kari.patila. Your suggestion led me down the right path. However, placing your suggestion in the body wasn't enough. Basically, to solve it, I had to add height: 100%; overflow: auto; and margin: 0; to the html and body. Thanks.
Add your comments
    Username Password
  • Format comments as (Help)