简体   繁体   中英

Dynamically loading an external JavaScript response

i'm usign this code to include dynamically js file in run-time:

var headID = document.getElementsByTagName("head")[0];
var script = document.createElement('script');
script.type='text/javascript';
script.src="js-debug/"+record.getId()+".js";

script.onload = function() {
      inizializeComponent();
}

for every node of menu, i include differente js file.

Now i need to intercept the event triggered when the page does not exist to show a messabox!

how can i geti it?

thanks!

使用script.onerror = function () { ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM