此代码不适用于 IE,但适用于 chrome 和 firefox。
我收到此错误消息 IE 控制台:SCRIPT5007: Unable to set value of the property 'href': object is null or undefined
<script>
$(document).on("ready", alternar_banner);
array_imagen = new Array(2);
array_imagen[0] = new Image(108,225);
array_imagen[0].src = "banner1.gif";
array_imagen[1] = new Image(108,225);
array_imagen[1].src = "banner2.gif";
array_url = new Array(2);
array_url[0] = 'http://www.google.com';
array_url[1] = 'https://www.yahoo.com';
contador = 0;
function alternar_banner(){
window.document["banner"].src = array_imagen[contador].src;
window.document.links["bannerref"].href = array_url[contador];
contador ++;
contador = contador % array_imagen.length;
setTimeout("alternar_banner()",6000);
}
</script>
<a name="bannerref" href="#"><img src="#" name="banner" width=108 height=225 border=0></a>