When we want to dynamically import js files, we can use the following method
var docFunc = {
/***************************************************** *************************
* purpose: Call the following dynamic loading script method load_script
************ *************************************************** **************/
loaddefJquery : function() {
//alert(ucapSession.hostPath ucapSession.appPath);
//ucapSession.appPath is the root directory
docFunc.load_script(ucapSession.appPath
"ftdxxglxt/js/jquery-1.8.1.min.js");
docFunc.load_script (ucapSession.appPath
"ftdxxglxt/js/jSuggest.js");
},
/***************************************************** ***************************
* purpose: dynamic loading script
****************** *************************************************** ***********/
load_script:function(url){
var x = new ActiveXObject("Msxml2.XMLHTTP");
x.open('GET', url, false);
x.send('');
eval(x.responseText);
var s = x.responseText.split(/n/);
var r = /^(?:function|var)s*([a-zA-Z_] )/i;
for (var i = 0; i < s.length; i )
{
var m = r.exec(s[i]);
if (m != null)
{
window[m[1]] = eval(m[1]);
}
}
}
}
in html page or jsp page calling method:
<script> <br> docFunc.loaddefJquery(); <br></script>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn