转载自:http://www.cnblogs.com/rubylouvre/archive/2012/02/03/2335946.html
//原题目:
window.alert = function(){};______;alert(1); 填空,使后面的alert(1)能正确弹出,至少列举两种不同思路。
解法一,创建新的执行环境,使用iframe沙箱
window.alert = function(){};
window.alert=function(obj){
var iframe=document.createElement("iframe");
iframe.src="javascript:void(0);"
document.body.appendChild(iframe)
iframe.contentWindow.alert(obj);
}
alert(1)
解法二,创建新的执行环境,打开新窗口
window.alert = function(){};
window.alert = function(a){
window.open('','').alert(a)
//window.createPopup().document.parentWindow.alert(a) //IE only
}
alert(1);