填空,使后面的 alert(0) 能正確彈出,至少列舉兩種不同思路。
window.alert = function () {};______;alert(0);
解:
方法一:
window.alert = function () {};delete window.alert;alert(0);
delete 操作符從入門到精通:https://developer.mozilla.org/en/JavaScript/Reference/Operators/delete
有個值得注意的地方,文中提到了操作符的返回值時,描述如下:
Returns false only if the property exists and cannot be deleted. It returns true in all other cases.
僅當屬性存在并且不可被刪除,則返回 false,否則一律返回 true
方法二:
創建一個 iframe ,獲取 iframe 的 window.alert 給當前頁面的 window.alert
來源:芒果小站 原文:點擊查看