html:<div class="centered-1"> <a href="canvas.html"><img src="images/reading-1.jpg" id="adBanner-1" alt="ad Banner"></a></div>css: .centered-1{width:200px;height: 200px;} .centered-1 img{ width:100%; height: 100%;}.centered-1 a{display: block;}js代码:window.onload=initBannerLink;var thisLink=0;function initBannerLink(){ if(document.getElementById("adBanner-1").parentNode.tagName=="A") { document.getElementById("adBanner-1").parentNode.onClick=newLocation; } rotate_1();}function newLocation(){ document.write("fjskdjs"); var adURL=new Array("http://www.google.com","http://www.sun.com","http://www.baidu.com"); document.location.href=adURL[thisLink]; return false;}function rotate_1(){ var adimgs=new Array("images/reading-1.jpg","images/reading-2.jpg", "images/reading-3.jpg"); thisLink++; if(thisLink==adimgs.length) { thisLink=0; } document.getElementById("adBanner-1").src=adimgs[thisLink]; setTimeout(rotate_1,2*1000);}
添加回答
举报
0/150
提交
取消