var url = URL address; var _script = document.createelement (' script '); _script.type = "Text/javascript"; _script.src = URL; Document.head.appendChild (_script);
The use of Ajax requests can not cross-domain, so find this string of code, can cross-domain, in Google Firefox above all measured, no problem, the program is all right, but in IE, there is a problem, prompting the code error,
Document.head.appendChild (Element) head is empty.
Change the document.head above to
var head = document.getElementsByTagName ("Head") [0];head.appendchild (Requiretag);
This will be OK. Compatible with all browsers.
----------------------------------------------------------------------------
The following is the code I found from the Internet, no test, I do not know whether to use, the back of the test
var Requiretag = document.createelement (' script '); Requiretag.setattribute (' type ', ' text/javascript '); requiretag.se Tattribute (' src ', link+ ' require.js '), Requiretag.setattribute (' Data-main ', link+ ' data ');d Ocument.head.appendC Hild (Requiretag);
This article is from the "Music" blog, be sure to keep this source http://boysmusic.blog.51cto.com/9398683/1758458
The document.head in JavaScript is not compatible with IE below.