Hello everyone, it’s my first pose in here.
I have a preload script here, but I don’t know why it is not working. Here is the code:
In page.js:
[code]
function Preloader() {
this.images=[];
this.elemRef=document.getElementById(arguments[0]);
for(var i=0, len=arguments.length; i<len; i++) {
this.images[i]=new Image();
this.images[i].src=arguments[i];
}
}
function Change(image, item) {
item.src = image;
}
In index.html (I declared my script in the header), inside BODY:
[code]
<script type=”text/javascript”>
Preloader(“menu1_o.gif”, “menu2_o.gif”);
</script>
… some html here …
<!– menu –>
<img src=”menu1.gif” onmouseover=”Change(‘menu1_o.gif’, this);” onmouseout=”Change(‘menu1.gif’, this);” />
<img src=”menu1.gif” onmouseover=”Change(‘menu2_o.gif’, this);” onmouseout=”Change(‘menu2.gif’, this);” />
The page and events work, except the preloader. I still have the delay when the mouse goes over the menu, because it is only downloading the over image when the event is triggered.
What am I doing wrong?
Thanks in advance,
Fergo