Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

load image last?

Status
Not open for further replies.

litton1

Technical User
Apr 21, 2005
584
GB
Is it possible to get an image to load after the page has loaded? I am trying streamline the pages and wondered if this was a possibility. If yes how should I go about it? I am very new to JavaScript so if anyone knows of a tutorial that would be great.
Thx in advance


Age is a consequence of experience
 
litton1,

The body "onload" event will work for this:

Code:
<html>
<head>
  <title></title>
<script type="text/javascript">
function loadImg(){
var loadedImg = new Image();
loadedImg.src = "[URL unfurl="true"]http://www.google.com/intl/en/images/logo.gif";[/URL]
var Img = document.getElementById('pic');
Img.src = loadedImg.src;
}
</script>
</head>
<body onload="loadImg()">
      <p>
      This is our first paragragh
      </p>
      <img id="pic" src="" alt="" border="0" />
</body>
</html>

Thanks,
--Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top