Include a JavaScript file in a JavaScript file
Possible Duplicate:
How to include a JavaScript file in another JavaScript file?
I want to include a JavaScript file in a JavaScript file. include('filename.js');
is not working
What is the right code?
function includeJS(incFile)
{
document.write('<script type="text/javascript" src="'+ incFile+ '"></script>');
}
然后通过调用包含第二个JavaScript文件:
includeJS('filename.js');
Use:
<script language="javascript" src="first.js"></script>
<script language="javascript" src="second.js"></script>
You can access the variables from the first file in the second file.
There isn't any need to include one JavaScript file into another. JavaScript code is globalised. You can include both the files in the HTML/JSP page.
在第一个JavaScript函数中使用document.write
:
document.write('<scr'+'ipt type="text/javascript" src="filename.js" ></scr'+'ipt>');
链接地址: http://www.djcxy.com/p/7338.html