SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Random background switching not working in IE

    Im trying to change the background on the "demo" div.

    This works perfectly in Firefox and Chrome but sadly not in IE.

    Any ideas?

    Code:
    function getImage(){
    	var r = Math.floor(Math.random()*5);
    	
    	var arrRotator = [];
    	
    		arrRotator[0]="rotator1w.jpg";
    		arrRotator[1]="rotator2w.jpg";
    		arrRotator[2]="rotator3w.jpg";
    		arrRotator[3]="rotator4w.jpg";		
    		arrRotator[4]="rotator5w.jpg";
    		
    		var b = document.getElementById('demo');
    		var s = arrRotator[r];
    		b.style.backgroundImage="url("+s+")";
    		
    	}

  2. #2
    Keep Moving Forward gold trophysilver trophybronze trophy
    Shaun(OfTheDead)'s Avatar
    Join Date
    Nov 2005
    Location
    Trinidad
    Posts
    3,726
    Mentioned
    43 Post(s)
    Tagged
    0 Thread(s)
    Try backgroundImage = s; (take out the "url( )" part).




    Trying to fill the unforgiving minute
    with sixty seconds' worth of distance run.

    Update on Sitepoint's Migration to Discourse


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
  •