关于javascript中的clearInterval停止不了的问题!!!急~
我崩溃了,为什么clearInterval之后,timer仍然在继续!!!????
关键在这一行。
我已经输出了,而且AdSwitch.thetimer_也是null,但是为什么autochange 仍然在继续???
达人求解!!!!!搞了半天了搞不订了!!!!!!
madmanahong@hotmail.com
/* 图片自动切换 */
autochange : function() {
AdSwitch.traceinfo( "!change timer " + AdSwitch.thetimer_ + "times = " + (++test));
if (!AdSwitch.thetimer_) {
return;
}
/// 为什么这个一直在继续?????AdSwitch.thetimer_已经是null了阿!!!!!!!!!!!!!!!!
}
==========================================
源代码:
<div id= "testid " style= "border:#000 1px solid;width:600px;height:200px;background-color:orange ">
</div>
<div id= "trace " style= "width:800;height:30; "> </div>
<script language= "javascript ">
var test = 0;
var AdSwitch = {
version_ : "1.0.0.0 ",
author_ : "madmanahong ",
copyright_ : "www.bj-lover.com ",
isload_ : false,
xmlpath_ : null,
xmlparser_ : null,
allad_ : Array(),
curidx_ : 0,
divid_ : null,
btncx_ : 25,
btncy_ : 25,
btnsep_ : 5,
imgdivid_ : "adswitch_img ",
timeinterval_ : 3000,
thetimer_ : null,
/* 加载广告的div */
load_xml : function(xmlpath) {
xmlpath_ = xmlpath;
if (window.ActiveXObject) {
this.xmlparser_ = new ActiveXObject( "Msxml2.DOMDocument ");
} else if (document.implementation&&document.implementation.createDocument) {
this.xmlparser_ = document.implementation.createDocument( " ", " ",null);
} else {
this.xmlparser_ = null;
return false;
}
this.xmlparser_.resolveExternals = false;
this.xmlparser_.async = false;
this.xmlparser_.load(xmlpath);
if (this.xmlparser_.parseError&&this.xmlparser_.parseError.errorCode) {
alert(this.xmlparser_.parseError.reason);
return false;
}
var elements = this.xmlparser_.getElementsByTagName( "aditem ");
if (elements) {
for (var i=0;i <elements.length;++i) {
var ele = elements[i];
this.allad_[i] = new Array();
for (var j=0;j <ele.childNodes.leng