After the native method of js is overwritten, if you haven’t made the native method point to a new variable name again, then it’s gg. Therefore, the key is how to obtain the native method again. The principle of implementation is to create a new window object, and then obtain the native methods from the new window object to reassign values.
First create an iframe object, use the document.createElement
method to create
var iframe = document.createElement("iframe");document.body.appendChild(iframe)
Then, get the iframe
The window
object inside
var iframeWin = iframe.contentWindow;
is finally assigned a value, and then
window.console = iframeWin.console;
window.open
Method call will open a new window and return a new window
object, so we can get the window
object like this
var win = window.open(); //获取对象 win.close(); //将打开的窗口关闭window.console = win.console;
Related recommendations:
PHP implementation code for reassigning a certain column of elements
The above is the detailed content of js reassign native method. For more information, please follow other related articles on the PHP Chinese website!