![]() |
|
#1
|
|||
|
|||
|
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:4fjv03sbmn] CSS <style> .bannerDiv {top: 5px; left: 2px; position: absolute;} </style> JavaScript function init() { document.getElementById('bannerDiv').style.backgro undImage = 'url("abc.jpg")'; } HTML <body onload="init()"> <div id="bannerDiv" class="bannerDiv"></div> </body> [/code:4fjv03sbmn] There is no error generated, but the image does not show in the layer also. Where am I going wrong? Please help. Peace, Shivboy [code:4fjv03sbmn]Just <code> it! [/code:4fjv03sbmn] |
|
#2
|
|||
|
|||
|
CSS
<style> .bannerDiv {top: 5px; left: 2px; position: absolute;} </style> JavaScript function init() { document.getElementById('bannerDiv').style.backgro und = 'url("abc.jpg"); } HTML <body> <div id="bannerDiv" class="bannerDiv"></div> <script> window.onload=function () {init();} </script> </body> |
|
#3
|
|||
|
|||
|
Try this:
HTML Code:
<style> #bannerDiv { top: 5px; left: 2px; width: 100px; position: absolute; } </style> JavaScript function init() { document.getElementById('bannerDiv').style.background = 'url("abc.jpg"); } <body> <div id="bannerDiv"></div> <script> window.onload=function () { init(); } </script> </body> |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|