Jump to content

Javascript Image Pre-Loader


McBryver

Recommended Posts

Ok all sites on google says this should work but it dosnt.

 

Javascript:

<head>
<script type="text/javascript">
function preloader() 

{
fresh = new Image(960,720)
fresh.src = "http://x-tremeclean.com/images/fresh.png"
}
</script>

</head>
<body id="top" onLoad="javascript:preloader()">

Image Code:

      <div class="floater">
        <h2>1. This carpet is the after picture of what we have done.</h2>
        <p>This is what we accomplish using our RX-20 Cleaning Device.</p>
      </div>
      <p class="readmore"><a href="#">Schedual Quote »</a></p>
      <img src="images/fresh.png" id="fresh" name="fresh" alt="" /> </div>

 

Any help would be cool.

McBryver

Link to comment
https://forums.phpfreaks.com/topic/213177-javascript-image-pre-loader/
Share on other sites

That is because you are calling the function on page load,after everything else has loaded.

 

Try this...

<script type="text/javascript">
<!--
fresh = new Image(960,720)
fresh.src = "http://x-tremeclean.com/images/fresh.png"
//-->
</script>

 

Instead of...

<script type="text/javascript">
function preloader()

{
fresh = new Image(960,720)
fresh.src = "http://x-tremeclean.com/images/fresh.png"
}
</script>

 

Regards, Paul.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.