有一个循环在IE上面创建面
for(var iIndex=0;iIndex<100;iIndex++){
var pPoints=getRandPolygon();
var strPoints=pPoints.join(",");
var poly=new Polygon(strPoints,"transparent", 0,0,"transparent");
var pBound =new Polyline(strPoints,"#ff0000", 1,0.7,1);
_MapApp.addOverlay(poly);
var strMsg= " 长度:"+poly.getLength()+",面积:"+poly.getArea();
poly.data = strMsg ;
poly.boundry = pBound ;
poly.addListener("mouseover",function(e){showtip(poly);});
poly.addListener("mouseout",function(){htm();});
}
为什么循环完了 以后鼠标mouseover 实体上showtip 执行的都是最后一个poly的内容????
你这个是在一个循环中赋值的, 后面的把前面的给覆盖了
try[
code=JScript]poly.addListener("mouseover",function(e){showtip(poly);});
poly.addListener("mouseout",function(){htm();});
------------
(function(){poly.addListener("mouseover",function(e){showtip(poly);});
poly.addListener("mouseout",function(){htm();});
})();[/code]
引用 闭包经典问题。。。 JScript code poly.addListener("mouseover",function(e){showtip(poly);}); //改为 poly.addListener("mouseover",function(p){ return function(e){
以下是一段JavsScript脚本,但运行时总会产生 “Microsoft JScript 运行时错误: 'null' 为空或不是对象”异常,大家帮看一下。 <form id="form1" runat="server"> < ......