不好意思,网上本来有例子的,可是试了不行,发贴求救的!
我的需求是这样的:
两个JS文件:a.js和b.js;
a.js的代码如下:document.write("<scr"+"ipt type='text/javascript' src='b.js'></scr"+"ipt>");
function a()
{
   alert("aaaaaa");
   b();
}
b.js代码如下:alert("载入b.js");
function b()
{
   alert("bbbbb");
}
然后我在html文件上只调用a.js文件,执行a()方法却出错。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>测试</title>
</head>
<script type="text/javascript" src="js/a.js"></script>
<script>

function test()
{
a();
}
</script>
<body onload="test()">
</body>
</html>说找不到b()。页面导入时,只弹出了“aaaaaa”,没有弹出“载入b.js”,证明不能载入b.js文件。
我的需求是html代码上只能写载入a.js文件,不能写b.js文件,请问各位高手有木有其他办法啊?