Online Demo Address http://www.jb51.net/jslib/Import/a.html
Main function Code Import.js
Copy Code code as follows:
<!--
(function () {
if (typeof window._import!= "undefined") return; Prevent multiple loads
function _import (URI, x) {
var f = arguments.callee.caller;
if (typeof f = = "function") {
var Isie = (navigator.userAgent.indexOf ("msie") = = 1)? False:true;
var Scriptele = document.getElementsByTagName ("Head") [0].appendchild (Document.createelement ("script"));
Scriptele.type = "Text/javascript";
Scriptele.src = URI;
if (x)
{
if (Isie) {
Scriptele.onreadystatechange = x;
}
else {
Scriptele.onload = x;
}
}
}
}
Window._import = _import;
})();
-->
Remote Test A.js
Copy Code code as follows:
var a = "cloud-dwelling community www.jb51.net===";
Specific calling code
Copy Code code as follows:
<title>-</title>
<body>
<script type= "Text/javascript" src= "Import.js" ></script>
<script type= "Text/javascript" >
(function () {
function callback ()
{
var Isie = (navigator.userAgent.indexOf ("msie") = = 1)? False:true;
if (Isie)
{
if (/loaded/.test (this.readystate))
{
alert (a);
}
}
Else
{
alert (a);
}
}
_import ("Http://www.jb51.net/jslib/Import/a.js", callback)
})()
</script>
</body>