You are here: irt.org | FAQ | JavaScript | Image | Q119 [ previous next ]
You can set the background using JavaScript whilst outputting the document to the browser window using something like:
<SCRIPT LANGUAGE="JavaScript"><!--
document.write('<BODY BACKGROUND=' + variablename + '>');
//--></SCRIPT>Or for Internet Explorer 4+ and Netscape Navigator 6+, you can use:
<html>
<head>
<script language="JavaScript"><!--
function setBackground() {
if (document.body) {
alert('here');
document.body.style.backgroundImage = 'url(image.gif)';
}
}
//--></script>
</head>
<body onLoad="setBackground()">
</body>
</html>