在页面结束时(跳转或关闭), DOJO会做一些处理:
dojo.unloaded = function(){
// summary:
// signal fired by impending environment destruction. You should use
// dojo.addOnUnload() instead of doing a direct dojo.connect() to this
// method to perform page/application cleanup methods. See
// dojo.addOnUnload for more info.
var mll = d._unloaders;
while(mll.length){
(mll.pop())();
}
}
如果有上传控件之类的包含SWF的,然后其中会有dojox.embed.Flash文件中的方法被执行:
// attach some cleanup for IE, thanks to deconcept :)
dojo.addOnUnload(function(){
var dummy = function(){};
var objs = dojo.query("object").
reverse().
style("display", "none").
forEach(function(i){
for(var p in i){
if((p != "FlashVars") && dojo.isFunction(i[p])){
try{
i[p] = dummy;
}catch(e){}
}
}
});
});
而此时如果页面有OBJECT的其他控件(如MEDIAPLAYER),则会导致报错, 所以对于此种情况需要先手动清除一下OBJECT:
dojo.addOnUnload(function(){
dojo.byId("soundShowPos").innerHTML='';
});
ps:经测试发现, if((p != "FlashVars") && dojo.isFunction(i[p])){ 这句代码会在
dojo.addOnUnload(function(){
dojo.byId("soundShowPos").innerHTML='';
});
之前执行,还是报错,达不到目的,我的做法是OBJECT调用过之后就执行dojo.byId("soundShowPos").innerHTML='';
原文:http://blog.163.com/eboge@126/blog/static/257055072010113193410832/