test1.js 
<script type="text/javascript"> 
function hello() 

    alert("hello!!!!!"); 

</script> test2.js 
<script src="webfun.js"> 
hello(); 
</script> 写错了吧

解决方案 »

  1.   

    给IE安装一个调试js的插件就可以知道错误了啊 
      

  2.   

    貌似不可以,只能在html中加载两个js文件,然后互相调用!
      

  3.   

    JS文件只简单的文件物理分割,
    在HTML文件中使用 <script src="...">直接包含,
    JS文件内部不用声明script.
    直接调用就以了。你可以这样考虑,
    你把HTML语句和JS语句分别放在了不同的文件里面.
    在画面装载的时候,
    浏览器根据指明的文件位置,
    把他们拼接到一起形成一个大文件.
    就这么回事儿.
      

  4.   

    .js 文件是不能写标签的:<script></script>
      

  5.   

    test1.js 
    <script type="text/javascript"> 
    function hello(item) 

        alert("test1.js  hello!!!!!"+item); 

    </script> test2.js 
    <script type="text/javascript" src="test1.js"></script> 
     
    <script type="text/javascript"> 
      hello(item) ;
    </script> test.html
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <script src="js/test2.js" type="text/javascript"> </script> 
    </head> 
    <body> 
    <input type="submit" onclick="hello()" name="sub"/> 
    </body> 
    </html> 
      

  6.   

    test1.js 
    function hello() 

        alert("test1.js  hello!!!!!"); 
    } test2.js 
    function hello2() 

        hello() ; 
    }test.html 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <script src="js/test2.js" type="text/javascript"> </script> 
    <script type="text/javascript" src="test1.js"> </script> 
    </head> 
    <body> 
    <input type="submit" onclick="hello2()" name="sub"/> 
    </body> 
    </html> 
      

  7.   

    只要两个js文件都加载到同一页面就可以共享方法和变量了
    test1.js 
    function hello() 

        alert("hello!!!!!"); 
    } test2.js 
    hello(); test.html 
    <!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> 
    <script src="js/test1.js" type="text/javascript"/> 
    <script src="js/test2.js" type="text/javascript"/> 
    </head> <body> 
    <input type="submit" onclick="hello()" name="sub"/> 
    </body> 
    </html> 
      

  8.   

    导入js文件习惯性的用"/>"结尾了 错了 应该是
    <script src="js/test1.js" type="text/javascript"></script> 
    <script src="js/test2.js" type="text/javascript"></script>
      

  9.   

    js代码是在客户端的浏览器中执行的,实际上我们每次请求之后,服务器端会将js代码一同发送给客户端,这样客户点就会将由服务器端发送过来的代码执行
    或者等待事件触发来执行
      

  10.   

    应该在test2.js里边引用test1.js,然后test2.js里边写个方法调用test1.js里边的js,在页面引用test2.js,并调用里边的方法,就等于直接调用了test1.js里边的hello()了
    跟绕口令似的
      

  11.   

    把两个JS文件一起加载到页面中就等于在页面中同时写了这两个文件中的方法,那当然就可以相互调用了
    <script src="js/test1.js" type="text/javascript"> </script> 
    <script src="js/test2.js" type="text/javascript"> </script>
      

  12.   

    js文件中不用添加<script></script>调用js文件写法<script src="scripts/myJs.js" type="text/javascript"></script>
      

  13.   


    汗!- -
    看来还是mm受欢迎啊,大家太热情了,O(∩_∩)O哈哈~
      

  14.   

    上面兄弟说对js文件里面不能写<script></script>的  js文件链接进来的时候就是在页面写js一样的你在js文件里再写那个标签好像就重复了吧?不知道这样理解对不对,望兄弟们纠正
      

  15.   

    上面兄弟说对js文件里面不能写<script></script>的  js文件链接进来的时候就是在页面写js一样的你在js文件里再写那个标签好像就重复了吧?不知道这样理解对不对,望兄弟们纠正