PDA

View Full Version : Stack overflow because of JS -why???



Binji
November 7th, 2006, 10:07 AM
I have a function which replaces one image with another originally meant for onmouseover function but i use also as a sort of PNG fix for IE. The idea is to have one pic loaded for FF and one for IE. The JS function looks like this:


var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function rollOver(ime, pot, over){
if ((version >= 5.5) && (version < 7) && (document.body.filters) && (!over))
{
document[ime].src='images/menu/'+ime+'.jpg';
//alert(document[ime].src);
}else if((version >= 5.5) && (version < 7) && (document.body.filters) && (over)){
document[ime].src='images/menu/'+ime+'_over.jpg';
}
else{
document[ime].src = pot;
}
}
so that the function loads different images depending on the type of browser and if the mouse is over the image. That works fine. But if i use it in IMG tag like this:


onload="rollOver('disko', 'images/menu/disko.png', false)"
it returns stackOverflow when i open the document. Why is that and how could i make it work?

Thanks in advance!

Binji
November 8th, 2006, 05:07 AM
Ok..my basic question is only how to replace images without having to hover with the mouse over them. My method doesnt work so i would like to know if someone has a better suggestion :) Appreciate it!

Binji
November 8th, 2006, 06:21 AM
well if anyone is interested..i got it working by putting an onload="preload()" function in body tag which displayed those pics