我在xx.htm代码里通过<script  type="text/javascript" src="1234.js"></script>调用了一个1234.js文件,1234.js文件里就一句代码:document.write('nihao');
可htm调试时怎么弄都是个空白页面,是什么原因,请高手指点!

解决方案 »

  1.   

    onload怎么调用,能说的具体点吗?我主要是想调用外部文件,不想将代码全写在一个文件里
      

  2.   

      呵呵 你在哪里写的<script>.....</script>将它下载body里应该可以,或者渲染的时候外部调用document.write不行
      

  3.   

    路径不对。要么就是这个script的容器被隐藏了
      

  4.   

    看下报错不,另外,在js的顶上加一句alert(123);测试一下调用了没有
      

  5.   

    script标签放在head里了?
    window.onload = function(){
        document.write('XXXX');
    }
      

  6.   

    其实在<script>导入js文件只是导入了,并没有使用,你需要使用它,才能看到有没有导入成功,另外,要在同一个文件夹下面,你也可以在加载页面的时候使用,调用window.onload();方法
      

  7.   

    我的目录结构是
    --html
      -- write.html
    --otherJs
      -- 1234.js
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>write</title>
    <script language="JavaScript" src="/otherJs/1234.js" type="text/javascript"></script>
    </head>
    <body></body>
    </html>
      

  8.   

    路径没有错,调试的时候报语法错误,错误指向了123.js的<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      

  9.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" >
    <title>时尚</title></head><body>
    <script  type="text/javascript"  src="../asp1/123.js" ></script></body>
    </html>
    /**************************************************/
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    document.write('nihao');
    </body>
    </html>