是从国外的一个网站上抄回来的。
Js内存泄漏,在IE里面好像没什么影响,但是如果在应用程序中使用了js脚本,问题就大了,特别是如果在Office插件里面的HtmlView控件里面的Js脚本,Office应用程序就突然退出了。
function ReleaseEvents()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
var events = ["focus", "blur", "change", "click", "mousedown",
"mouseup", "mouseover", "keypress", "keydown",
"keyup", "keypress"];
![](/Images/OutliningIndicators/InBlock.gif)
var helper = function(obj)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
var i;
for (i = 0; i < events.length; i++)
obj["on" + events[i]] = null;
for (i = 0; i < parent.childNodes.length; i++)
helper(parent.childNodes[i]);
}
![](/Images/OutliningIndicators/InBlock.gif)
helper(document);
}
window.onunload = ReleaseEvents;