日期:2014-05-16 浏览次数:20376 次
< html > < head > < script language = “ JScript “ > function AttachEvents(element) { // This structure causes element to ref ClickEventHandler element.attachEvent( “ onclick “ , ClickEventHandler); function ClickEventHandler() { // This closure refs element } } function SetupLeak() { // The leak happens all at once AttachEvents(document.getElementById( “ LeakedDiv “ )); } </ script > </ head > < body onload = “ SetupLeak() “ > < div id = “ LeakedDiv “ ></ div > </ body > </ html >
function BreakLeak() { document.getElementById(”LeakedDiv”).detachEvent(”onclick”, document.getElementById(”LeakedDiv”).expandoClick); document.getElementById(”LeakedDiv”).expandoClick = null; }