Home >Web Front-end >JS Tutorial >js reassign native method

js reassign native method

小云云
小云云Original
2018-03-14 17:51:052615browse


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.

Use iframe implementation

First create an iframe object, use the document.createElement method to create

var iframe = document.createElement("iframe");document.body.appendChild(iframe)

Then, get the iframeThe window object inside

var iframeWin = iframe.contentWindow;

is finally assigned a value, and then

window.console = iframeWin.console;

uses the window.open method to implement

window.openMethod 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn