I use a third party ad server to deliver the advertisements on my site. There are two invocation methods: IFRAME and JavaScript. I currently use the IFRAME method because it allows the full webpage to render independently of the ads ... in other words, without slowing down browser rendering time contacting and downloading images or flash animation from a third party server. I don't want the page content to be delayed being displayed because of a slow ad server or large flash animated ad. However, the JavaScript version is more full featured. Is there a way that I could use the JavaScript version while telling the browser not to execute it until the end? What if I were to include the JavaScript via an external file instead of inline?

don't know if this is what you are looking for or if it will help, but if you call a javascript function via the onload event in the body tag, it will not run until the page is fully loaded.

<body onload="doWhatever();">

Glad to help the csgal.

Campkev is correct. Here is how I do it.

<html>
<head>
<title>My Web Page</title>
<script type="text/javascript">
function LoadTrigger()
{
  alert('This will fire after the page has finished loading.');
}
window.onload = LoadTrigger;
</script>
</head>
<body>
  <p>
	 My Web Page is great!
  </p>
</body>
</html>

Thanks, guys. Appreciate the help! I will have to play around with this because my JavaScript code uses document.writes so I need to implement them inline where they belong. :) Will work on it and let you guys know!

To ensure the page is loaded before the add is drawn you can use a setTimeout(yourfunction,500) type mechanism in the onLoad.

You can also look at using the html dom to add innerHTML instead of using document.write

This can be done at any time... you could even set up a script that rotates your adds every minute or so (also by manipulating the innerHTML of DOM nodes).

Because I'm using a third party ad server, I don't have access to the script, itself (such as editing the document.writes). All I can do is call the <script> which is located on a remote server.

CSGal, did you ever find a solution to this crazy problem? I've been wrestling with this problem as well.

Thanks!

Maybe this will work:

<html>
<head>
<title>My Web Page</title>
<script language="javascript">
function LoadTrigger(){
	document.getElementById("AdServer").innerHTML = "<iframe.....></iframe>";
}
window.onload = LoadTrigger;
</script>
</head>
<body>
<!-- Placeholder for the iframe -->
<div id="AdServer"></div>
</body>
</html>
This article has been dead for over six months. Start a new discussion instead.