PDA

View Full Version : Unable to change background image of a layer



shivboy
11-05-2006, 06:25 PM
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:


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

mburt
11-05-2006, 06:31 PM
You need to specify a width and height for the div container, then it should appear :)

ddadmin
11-06-2006, 01:25 AM
Shivboy, please do not cross post, and also, post in the correct forum. Your thread is duplicated here (http://www.dynamicdrive.com/forums/showthread.php?t=13541) already. Closing this one.

Read the posting rules here (http://www.dynamicdrive.com/forums/rules.htm).