Results 1 to 3 of 3

Thread: Unable to change background image of a layer

  1. #1
    Join Date
    Sep 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Unable to change background image of a layer

    Hi,

    I've been trying to change the background image of a layer using JS, but in vain. The code that I am using is as follows:

    Code:
    CSS
    
    <style>
    .bannerDiv {top: 5px; left: 2px; position: absolute;}
    </style>
    
    JavaScript
    
    function init()
    {
    document.getElementById('bannerDiv').style.backgroundImage = 'url("abc.jpg")';
    }
    
    HTML
    
    <body onload="init()">
    
    <div id="bannerDiv" class="bannerDiv"></div>
    
    </body>
    There is no error generated, but the image does not show in the layer also. Where am I going wrong? Please help.

    Peace,

    Shivboy

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    You need to specify a width and height for the div container, then it should appear
    - Mike

  3. #3
    Join Date
    Aug 2004
    Posts
    9,878
    Thanks
    3
    Thanked 962 Times in 951 Posts
    Blog Entries
    15

    Default

    Shivboy, please do not cross post, and also, post in the correct forum. Your thread is duplicated here already. Closing this one.

    Read the posting rules here.

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
  •