Every line of 'javascript load url' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
30 function loadScript(url, callback){ 31 32 var script = document.createElement("script"); 33 script.type = "text/javascript"; 34 35 if (script.readyState){ //IE 36 script.onreadystatechange = function(){ 37 if (script.readyState == "loaded" || 38 script.readyState == "complete"){ 39 script.onreadystatechange = null; 40 callback(); 41 } 42 }; 43 } else { //Others 44 script.onload = function(){ 45 callback(); 46 }; 47 } 48 49 script.src = url; 50 document.getElementsByTagName("head")[0].appendChild(script); 51 }
27 function LoadScript( url ) 28 { 29 document.write( '<\/scr' + 'ipt>' ) ; 30 31 }
27 function LoadScript( url ) 28 { 29 document.write( '<\/scr' + 'ipt>' ) ; 30 31 }
27 function LoadScript( url ) 28 { 29 document.write( '<\/scr' + 'ipt>' ) ; 30 31 }
1 function loadScript(url, callback){ 2 alert('url'); 3 var script = document.createElement("script") 4 script.type = "text/javascript"; 5 6 if (script.readyState){ //IE 7 script.onreadystatechange = function(){ 8 if (script.readyState == "loaded" || 9 script.readyState == "complete"){ 10 script.onreadystatechange = null; 11 callback(); 12 } 13 }; 14 } else { //Others 15 script.onload = function(){ 16 callback(); 17 }; 18 } 19 20 script.src = url; 21 document.getElementsByTagName("head")[0].appendChild(script); 22 23 }
1 function loadJS(url, isExternal) 2 { 3 if( isExternal ) 4 url = document.location.protocol == 'file:' ? 'http:' + url : url; 5 else 6 url += '?v=' + app.version + (!app.isProduction ? '&_=' + new Date().getTime() : ''); 7 8 var ref = window.document.getElementsByTagName('script')[0]; 9 var script = window.document.createElement('script'); 10 script.src = url; 11 script.async = false; 12 ref.parentNode.insertBefore(script, ref); 13 }
35 function loadScript(url, callback) 36 { 37 var script = document.createElement("script") 38 script.type = "text/javascript"; 39 40 if (script.readyState) 41 { // IE 42 script.onreadystatechange = function() 43 { 44 if (script.readyState == "loaded" || script.readyState == "complete") 45 { 46 script.onreadystatechange = null; 47 callback(); 48 } 49 }; 50 } else 51 { // Others 52 script.onload = function() 53 { 54 callback(); 55 }; 56 } 57 58 script.src = url; 59 document.getElementsByTagName("head")[0].appendChild(script); 60 }
42 export function loadScript(url, callback) { 43 if (isNodeEnv()) { 44 return 45 } 46 47 var head = document.getElementsByTagName('head')[0]; 48 var script = document.createElement('script'); 49 script.type = 'text/javascript'; 50 script.src = url; 51 //借鉴了jQuery的script跨域方法 52 script.onload = script.onreadystatechange = function(){ 53 if((!this.readyState||this.readyState === 'loaded'||this.readyState === 'complete')){ 54 callback && callback(); 55 // Handle memory leak in IE 56 script.onload = script.onreadystatechange = null; 57 } 58 }; 59 head.appendChild(script); 60 }
4 function loadScript(url, callback) 5 { 6 // Adding the script tag to the head as suggested before 7 var head = document.getElementsByTagName('head')[0]; 8 var script = document.createElement('script'); 9 script.type = 'text/javascript'; 10 script.src = url; 11 12 // Then bind the event to the callback function. 13 // There are several events for cross browser compatibility. 14 script.onreadystatechange = callback; 15 script.onload = callback; 16 17 // Fire the loading 18 head.appendChild(script); 19 }
17 function loadScript(url) { 18 var script = document.createElement('script'); 19 script.src = url; 20 var firstScript = document.getElementsByTagName('script')[0]; 21 firstScript.parentNode.insertBefore(script, firstScript); 22 }