Javascript examples for DOM HTML Element:Script
Handle loading script error with <script> onload and onerror method
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//from w w w . j a v a 2s. co m var script = document.createElement('script'); document.getElementsByTagName("head")[0].appendChild(script); script.onload = function() { console.log('loaded'); } script.onerror = function() { console.log('foo!'); } script.src = 'http://wrongServerYourAAAAAAA.com/script.js'; }); </script> </head> <body> </body> </html>