初学Javascript做了个测试就是提示缺少对象,请告诉我错在哪里?
helloworld.html
<html>
<head>
<title>Example HTML Page </title>
</head>
<body>
<input type="button" value="点击我" onclick="sayHello()">
<script type="text/javascript" src="example1.js"></script>
</body>
</html>
example1.js
<script typt="text/javascript">
function sayHello(){
alert("Hello Javascript"); }
</script>

解决方案 »

  1.   

    helloworld.html
    example1.js
    这两个文件放在一起吗?可能是路径找不到吧。
      

  2.   

    <script type="text/javascript" src="example1.js"></script>看看路径对不对~·
      

  3.   

    example1.js 不要 script 标签function sayHello(){
    alert("Hello Javascript");}
      

  4.   

    <input type="button" value="点击我" onclick="sayHello()">
    <script type="text/javascript" src="example1.js"></script> //这个js是在同一文件下吗?
    </body>
    </html>
    <script typt="text/javascript">
    function sayHello(){
      alert("Hello Javascript");
    }
    </script>
      

  5.   

    两个文件放在同一个目录下,example1.js 不要 script 标签
      

  6.   

    我晕,你单独创建js文件写js代码就不需要<script type="text/javascript"></script>了呀,把这个标签去就好了
      

  7.   

    js 文件里面不需要<script typt="text/javascript"> 标签