
June 20th, 2004, 09:41 AM
|
|
Contributing User
|
|
Join Date: Mar 2004
Location: Stockport, UK
Posts: 463
Time spent in forums: 23 h 32 m 47 sec
Reputation Power: 0
|
|
|
Image preloader not working in IE
Yo ppl
well heres what I'm usin for my image rollovers which preloads them aswell (surposedly)
Code:
<script type="text/javascript">
<!--
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}
/************************************************** **
* DOM Image rollover:
* by Chris Poole
* http://chrispoole.com
* Script featured on http://www.dynamicdrive.com
* Keep this notice intact to use it :-)
************************************************** **/
function init() {
if (!document.getElementById) return
var imgOriginSrc;
var imgTemp = new Array();
var imgarr = document.getElementsByTagName('img');
for (var i = 0; i < imgarr.length; i++) {
if (imgarr[i].getAttribute('hsrc')) {
imgTemp[i] = newImage(imgarr[i].getAttribute('hsrc'));
imgarr[i].onmouseover = function() {
imgOriginSrc = this.getAttribute('src');
this.setAttribute('src',this.getAttribute('hsrc'))
}
imgarr[i].onmouseout = function() {
this.setAttribute('src',imgOriginSrc)
}
}
}
}
// -->
</script>
This works perfectly in Mozilla but not in MSIE can anybody help me with this Im not very good at Javascript.
btw to use the image rollovers you simply put an image in your page and add an extra tag 'hsrc' containing the mouseover image. eg.
[img]images/btn_tutorials.gif[/img]
|