Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q119 How can I change the background image?

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>

Feedback on 'Q119 How can I change the background image?'

©2018 Martin Webb