SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change DIV background using Javascript

    I currently have a web site in which I am using some Javascript to change the Background of a DIV.

    The DIV is defined as follows :

    <div id="outerscreen">
    <div id="mainscreen">
    </div>
    </div>


    and the Javascript I am using is as follows :

    var docEl = document.getElementById('outerscreen'); docEl.style.backgroundImage = "url('pics/intro.gif')";

    My problem arises where this function works perfectly on IE but fails for Chrome, FF and Safari.

    Can anyone shed any light on what the problem is and how I might be able to resovle this.

    Thanks in advance Chris

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,189
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Its hard to say whats going wrong as the code you posted should be 100% perfect in all browsers. Is there a demo link you could share with us?

  3. #3
    SitePoint Member
    Join Date
    May 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    he website is here frances-white.com it works just dandy in IE, however when in Chrome or FF the image does not load.

    Because i have a redirect on the URL it may be better seen here http://www.whitecoles.co.uk/lifecoaching/

    The source code in question appears on line 12 - 13 or there abouts

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,189
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I had a quick look and the background color for #mainscreen is the reason why nothing is appearing, simply remove the background color and the image will appear.


Tags for this Thread

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
  •