You are here: irt.org | FAQ | JavaScript | document | Q1429 [ previous next ]
<html> <head> <script language=javascript> function changeBg(layername) { if (document.all) document.all(layername).style.backgroundColor="#ff0000"; else if (document.layers) document.layers[layername].bgColor='red' } function changeBgImg(layername) { if (document.all) document.all(layername).style.background='url(http://www.irt.org/images/irt-sm.gif)'; else if (document.layers) document.layers[layername].background.src='http://www.irt.org/images/irt-sm.gif'; } </script> </head> <body> <layer name=layer1> <div id=layer1> This is the layer </div> </layer> <br> <a href=javascript:;changeBgImg('layer1')>change image!</a> <a href=javascript:changeBg('layer1')>change colour!</a> </body> </html>