Home > Web Front-end > JS Tutorial > How to implement reassignment using js

How to implement reassignment using js

亚连
Release: 2018-06-14 10:48:47
Original
3381 people have browsed it

Below I will share with you an article about how a js native method is overwritten and the native method is reassigned. It has a good reference value and I hope it will be helpful to everyone.

Implementation Principle

# After the native method of js is overwritten, if you have not 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 window object in the iframe

var iframeWin = iframe.contentWindow;
Copy after login

Finally assign a value, you can

window.console = iframeWin.console;
Copy after login

Use the window.open method to achieve

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

The above is what I compiled Everyone, I hope it will be helpful to everyone in the future.

Related articles:

How to implement bind in Javascript

How to implement encapsulation based on the mssql module in nodejs

How to implement the directive function in vue

How to prevent repeated rendering using React

How to implement grid using vue -layout function

Detailed introduction to adding drag and drop function to Modal in Bootstrap

How to achieve preview effect in JS

Make a project using three.js

How to use ES6 syntax in Node (detailed tutorial)

In How to configure Sass in vue scaffolding

The above is the detailed content of How to implement reassignment using js. 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