View Full Version : IE6 waits before triggering onload

01-19-2009, 11:40 PM
Hi all,
I have tried to use a simple javascript function to reformat a page after loading. However, IE6 (on Win XP, both 6.0.2900 and 6.0.0-something) sometimes (the problem is not consistent) waits before executing the function given in the onload tag of the body element. It appears as if it was waiting for the web server, but immediately continues if the user triggers something on the page. Then, miraculously, the problem disappears, and IE executes the script every time as expected. The problem appears to occur after booting for a couple of page loads.

In one case when the problem persisted for several page reloads, I've managed to comment everything out of the called function except an alert(), so I'm pretty sure the function itself was not called. The alert appeared only when I moved the cursor over an element which created a new div; then IE continued normally, called the function, and finished loading the page. Any ideas what might cause this behaviour? Please see the relevant code and the page structure below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript">
function myonload(){
if (navigator.appName.indexOf("Microsoft")!=-1) {
<body onload="myonload();">
<table style="width:100%;">
<tr id="headertr"> ... </tr>
<tr id="middletr">
<td> ... </td>
<td id="contenthold">
<div id="contentid"> ... </div>
<td> ... </td>
<tr id="footertr"> ... </tr>

Many thanks!