Sometimes you need to dynamically introduce a piece of JavaScript after loading a DIV in the webpage. The solution under IE is as follows:
Reference content is as follows:Newjs. onreadystatechange = function (){
If (newjs. readystate = 'loaded '){
// Ready!
}
}
Newjs. onload = function (){
// Ready!
}
Onload and onreadystatechange events are mainly used. This can also be used to dynamically load external C
Example 1. Reload JS file
The code is as follows
Copy Code
function Loadjs (file) {var head = $ ("head"). Remove ("script[role= ' reload ')");$ ("}
Example 2. The way to reload the JavaScript file (set an ID for JS) and encapsulate it in a way that is easy for everyone to use:
The code is as follows
Copy Code
function Reloadablejsfn (ID,NEWJS){var oldjs = null;var t = null;var Oldjs =
You can view the instances directly by loading JS files dynamically.
Example 1 reload the js File
The Code is as follows:
Function loadJs (file ){Var head = $ ("head"). remove ("script [role = 'reload']");$ ("
"+""). Attr ({role: 'reload', src: file, type: 'text/javascript '}). appendTo (head );
}
Example 2 How to reload a javascript file (set an id for js) and encapsulate it into a method for your convenience:
The Code is as follows:
Function reloadAbleJSFn (id,
You can view the instances directly by loading JS files dynamically.
Example 1 reload the js File
The Code is as follows:
Function loadJs (file ){Var head = $ ("head"). remove ("script [role = 'reload']");$ ("
"+""). Attr ({role: 'reload', src: file, type: 'text/javascript '}). appendTo (head );
}
Example 2 How to reload a javascript file (set an id for js) and encapsulate it into a method for your convenience:
The Code is as follows:
Function reloadAbleJSFn (id,
Look directly at the example.
Example 1 reload the JS file
Copy Code code as follows:
function Loadjs (file) {
var head = $ ("head"). Remove ("script[role= ' reload ')");
$ ("}
Example 2 reload the JavaScript file method (give JS set an ID), encapsulation into a method for everyone to use:
Copy Code code as follows:
function Reloadablejsfn (ID,NEWJS)
{
var oldjs = null;
var t = null;
var Oldjs = docume
the constructor as a class, this way is transformed from the back end of the 2, to do property and method inheritance, to separate inherit * *///parent function Aaa () {this.name = [];} Aaa.prototype.showName = function () {alert (this.name)}//sub-class function Bbb () {Aaa.call (this)}//this is a constructor, there is no property or method in this function , avoid attribute inheritance var F = function () {}f.prototype = aaa.prototype;//so when B receives the prototype, it can only receive t
$ (' demo '). On (' click ', ' span ', (event) =>{Let Url2 = event.currenttarget.offsetparent.childnodes[0].nodevalue;//gets the content of the parent element of the clicked spanLet Oinput = document.createelement (' input ');//Create an inputOinput.value = URL2;Document.body.appendChild (Oinput);Oinput.select (); Select ObjectDocument.execcommand ("Copy"); Perform a browser copy commandOinput.classname = ' oinput ';Oinput.style.display= ' None ';})Support for compatible Chrome/ff/ie>9/safari
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.