views:

220

answers:

1

For some reason when I run my game in IE it stops during the preloader. I opened up IE8's debugger and it failed on this line complaining about some run time error.

document.getElementById("mainpreloaderscreen").innerHTML=loaded+"/"+total+"<br><button onclick=\"gamepreload('all')\">load all (not  recomended)</button>";

Why does IE do this and how can I fix it?

heres the entire function

    function gamepreload(item)
{
loaded++;
total=18;
document.getElementById("mainpreloaderscreen").innerHTML=loaded+"/"+total+"<br><button onclick=\"gamepreload('all')\">load all (not  recomended)</button>";

if(item==0||item=='all'){gamepreloadstuff[0]=new Image();   gamepreloadstuff[0].onload=function(){gamepreload(1)}; gamepreloadstuff[0].src="images/menusignpoll.jpg";document.getElementById("img-menusignpoll").src=gamepreloadstuff[0].src;           }
if(item==1||item=='all'){gamepreloadstuff[1]=new Image();   gamepreloadstuff[1].onload=function(){gamepreload(2)}; gamepreloadstuff[1].src="images/menusignnewbutton.png";document.getElementById("img-menusignnewbutton").src=gamepreloadstuff[1].src;        }
if(item==2||item=='all'){gamepreloadstuff[2]=new Image();   gamepreloadstuff[2].onload=function(){gamepreload(3)}; gamepreloadstuff[2].src="images/menusignnewbutton-glowing.png";                         }
if(item==3||item=='all'){gamepreloadstuff[3]=new Image();   gamepreloadstuff[3].onload=function(){gamepreload(4)}; gamepreloadstuff[3].src="images/menusignresumebutton.png";document.getElementById("img-menusignresumebutton").src=gamepreloadstuff[3].src;       }
if(item==4||item=='all'){gamepreloadstuff[4]=new Image();   gamepreloadstuff[4].onload=function(){gamepreload(5)}; gamepreloadstuff[4].src="images/menusignresumebutton-glowing.png";                         }
if(item==5||item=='all'){gamepreloadstuff[5]=new Image();   gamepreloadstuff[5].onload=function(){gamepreload(6)}; gamepreloadstuff[5].src="images/menusignhelpbutton.png";document.getElementById("img-menusignhelpbutton").src=gamepreloadstuff[5].src;        }
if(item==6||item=='all'){gamepreloadstuff[6]=new Image();   gamepreloadstuff[6].onload=function(){gamepreload(7)}; gamepreloadstuff[6].src="images/menusignhelpbutton-glowing.png";                         }
if(item==7||item=='all'){gamepreloadstuff[7]=new Image();   gamepreloadstuff[7].onload=function(){gamepreload(8)}; gamepreloadstuff[7].src="images/menusignscoresbutton.png";document.getElementById("img-menusignscoresbutton").src=gamepreloadstuff[7].src;       }
if(item==8||item=='all'){gamepreloadstuff[8]=new Image();   gamepreloadstuff[8].onload=function(){gamepreload(9)}; gamepreloadstuff[8].src="images/menusignscoresbutton-glowing.png";                         }
if(item==9||item=='all'){gamepreloadstuff[9]=new Image();   gamepreloadstuff[9].onload=function(){gamepreload(10)}; gamepreloadstuff[9].src="images/menusignoptionsbutton.png";document.getElementById("img-menusignoptionsbutton").src=gamepreloadstuff[9].src;      }
if(item==10||item=='all'){gamepreloadstuff[10]=new Image(); gamepreloadstuff[10].onload=function(){gamepreload(11)}; gamepreloadstuff[10].src="images/menusignoptionsbutton-glowing.png";                        }
if(item==11||item=='all'){gamepreloadstuff[11]=new Image(); gamepreloadstuff[11].onload=function(){gamepreload(12)}; gamepreloadstuff[11].src="images/menusigncreditsbutton.png";document.getElementById("img-menusigncreditsbutton").src=gamepreloadstuff[11].src;      }
if(item==12||item=='all'){gamepreloadstuff[12]=new Image(); gamepreloadstuff[12].onload=function(){gamepreload(13)}; gamepreloadstuff[12].src="images/menusigncreditsbutton-glowing.png";                        }
if(item==13||item=='all'){gamepreloadstuff[13]=new Image(); gamepreloadstuff[13].onload=function(){gamepreload(14)}; gamepreloadstuff[13].src="images/menusignleaves.png";document.getElementById("img-menusignleaves").src=gamepreloadstuff[13].src;         }
if(item==14||item=='all'){gamepreloadstuff[14]=new Image(); gamepreloadstuff[14].onload=function(){gamepreload(15)}; gamepreloadstuff[14].src="images/menubox.png";document.getElementById("img-menubox").src=gamepreloadstuff[14].src;             }
if(item==15||item=='all'){gamepreloadstuff[15]=new Image(); gamepreloadstuff[15].onload=function(){gamepreload(16)}; gamepreloadstuff[15].src="images/menusavedindents.png";document.getElementById("img-menusavedindents").src=gamepreloadstuff[15].src;             }
if(item==16||item=='all'){gamepreloadstuff[16]=new Image(); gamepreloadstuff[16].onload=function(){gamepreload(17)}; gamepreloadstuff[16].src="images/mainbackbutton.png";document.getElementById("img-mainbackbutton").src=gamepreloadstuff[16].src;             }
if(item==17||item=='all'){gamepreloadstuff[17]=new Image(); gamepreloadstuff[17].onload=function(){gamepreload(18)}; gamepreloadstuff[17].src="images/mainbackbutton-glowing.png";                        }
if(item==18||item=='all'){document.getElementById("mainpreloaderscreen").style.display="none";}
}

The IE 8 debugger says "breaking on JSruntime error -(n

It works in FF and chrome

+1  A: 

My guess is that the DOM is not loaded when you make that call. Attach that code to the onload event.

geowa4
it is in an onload
Jcubed
hmm. need more info then. like more code, more detailed description.
geowa4
I added some more to original Q
Jcubed
the only thing i can think to do is append children rather than using `innerHTML`. that looks fine to me.
geowa4