Home > Web Front-end > JS Tutorial > body text

js reassign native method

小云云
Release: 2018-03-14 17:51:05
Original
2586 people have browsed it


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)
Copy after login

Then, get the iframeThe window object inside

var iframeWin = iframe.contentWindow;
Copy after login

is finally assigned a value, and then

window.console = iframeWin.console;
Copy after login

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;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template