window.onload = rolloverInit;
function rolloverInit() {
for (var i=0; i<document.links.length; i++)
var linkObj = document.links[i];
if (linkObj.className) {
var imgObj = document.getElementById(linkObj.className);
if (imgObj) {
setupRollover(linkObj,imgObj);
}
}
}
}
function setupRollover(thisLink,textImage) {
thisLink.imgToChange = new Array;
thisLink.outImage = new Array;
thisLink.overImage = new Array;
thisLink.imgToChange[0] = textImage;
thisLink.onmouseout = rollOut;
thisLink.onmouseover = rollOver;
thisLink.outImage[0] = new Image();
thisLink.outImage[0].src = textImage.src;
thisLink.overImage[0] = new Image();
thisLink.overImage[0].src = "images/" + thisLink.id + "Text.gif";
var rolloverObj = document.getElementById(thisLink.id + "Img");
if (rolloverObj) {
thisLink.imgToChange[1] = rolloverObj;
thisLink.outImage[1] = new Image();
thisLink.outImage[1].src = rolloverObj.src;
thisLink.overImage[1] = new Image();
thisLink.overImage[1].src = "images/" + thisLink.id + "_on.gif";
}
}
function rollOver() {
for (var i=0;i<this.imgToChange.length; i++) {
this.imgToChange[i].src = this.overImage[i].src;
}
}
function rollOut() {
for (var i=0;i<this.imgToChange.length; i++) {
this.imgToChange[i].src = this.outImage[i].src;
}
}
window.onload = rotate;
var thisAd = 0;
function rotate() {
var adImages = new Array("a38.png","a37.jpg","a36.png");
thisAd++;
if (thisAd == adImages.length) {
thisAd = 0;
}
document.getElementById("adBanner").src = adImages[thisAd];
setTimeout(rotate, 2 * 1000);
}
window.onload = initAll;
function initAll(){
document.getElementById("过去").onclick=saysomething;
document.getElementById("现在").onclick=saysomething;
document.getElementById("未来").onclick=saysomething;
}
function saysomething(){
switch(this.id){
case "过去":
alert("过去就是一首诗,思念的美");
break;
case "现在":
alert("现在就是一曲歌,旋律的荡漾");
break;
case "未来":
alert("未来就是一道桥,神秘且向往");
break;
default:
}
}
直接不是回过你了,要用attachEvent或者addEventListener,不能直接window.onload=xxxx来添加事件
function addEvent(o,evt,func){
if(o.attachEvent)o.attachEvent('on'+evt,func);
else if(o.addEventListener)o.addEventListener(evt,func,false);
}
//window.onload = rolloverInit;
addEvent(window,'load',rolloverInit)
//window.onload = initAll;
addEvent(window,'load',initAll)
//window.onload = rotate;
addEvent(window,'load',rotate)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。