|
-
Jun 19th, 2002, 11:08 AM
#1
Thread Starter
Junior Member
Change div and layer background in netscape 4.75 with javascript
Hi there,
is there any possibility to change background-images of a div or a layer in Netscape 4.75 by means of javascript?
The problem is the following:
I manage to change the background of a layer (is it possible for divs too??) but the problem is, that I am not able to turn background-repeat = "no-repeat". This is a style - function and I put the style for the layer and for the div. But when I change the background dynamically, it seems to have no effect.... .
What I do is the following:
I have a Java-Script file containing the following lines in one function:
document.menuImage.background.src=$img.src;
in the html - file I have declared the following layer-object:
<layer height="42" id="menuImage" style="background-repeat:no-repeat;"></layer>
the image changes properly, but the background-repeat is one.
Does someone know why? I would really be very grateful
Thx
Yours
Jeb
-
Jun 20th, 2002, 04:04 AM
#2
Fanatic Member
Netscape 4 doesnt work that way. Although you can use the style attribute, it is not supported in the same way as Mozilla.
Try something like this : -
Code:
<html>
<head>
<script language="javascript" type="text/javascript">
function changeBgImage(layerID,urlName){
document.layers[layerID].bgImage=urlName;
}
</script>
</head>
<body>
<layer id="layer1" width="200" height="200" background="http://yourdomain.com/image1.jpg" onMouseOver="javascript:changeBgImage('layer1','http://yourdomain.com/image2.jpg')" onMouseOver="javascript:changeBgImage('layer1','http://yourdomain.com/image1.jpg')">
</layer>
</body>
</html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|