Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q119 How can I change the background image?

irt.org | Knowledge Base | JavaScript | Image | Q119 [ previous next ]

Q119 How can I change the background image?

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.