在一个html中调用两个javascript为什么不能同时运行。。急!!

 <script  src="script01.js"></script>
 <script  src="script02.js"></script>

这是script01.js

 window.onload = choosePic;

var adImages = new Array("images/3.jpg","images/2.jpg","images/113.jpg");
var thisAd = 0;

function choosePic() {
    thisAd = Math.floor((Math.random() * adImages.length));
    document.getElementById("adBanner").src = adImages[thisAd];

    rotate();
}

function rotate() {
    thisAd++;
    if (thisAd == adImages.length) {
        thisAd = 0;
    }
    document.getElementById("adBanner").src = adImages[thisAd];

    setTimeout(rotate, 2 * 1000);
}

这是script02.js

 window.onload = initAll;  
function initAll() {      var allLinks = document.getElementsByTagName("a");       for (var i=0; i<allLinks.length; i++) {         if (allLinks[i].className.indexOf("menuLink") > -1) {            allLinks[i].onclick = toggleMenu;         }      } }  
function toggleMenu() {      var startMenu = this.href.lastIndexOf("/")+1;      var stopMenu = this.href.lastIndexOf(".");  
     var thisMenuName = this.href.substring(startMenu,stopMenu);      var thisMenu = document.getElementById(thisMenuName).style;      if (thisMenu.display == "block") {         thisMenu.display = "none";      }      else {         thisMenu.display = "block";      }  
     return false; } 
查看全部
qq_28608481
Tina-IT
2015/06/06 05:41
  • html5
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复