为什么会用<object>呢?不知你是不是想这样?
<script src = "xxxx.js"></script> 还是想访问子窗口中的函数~

解决方案 »

  1.   

    还是想访问子窗口中的函数~=====================
    就是想访问子窗口<object>中的方法
      

  2.   

    你的写法有错误啊虽然scriptlet里面有定义函数,但是你没有暴露出来啊,外部是无法调用的
      

  3.   

    t.htm
    -------------------------------------------------<html>
    <script>
    function public_getname(){    //注意使用public 暴露getname函数
    return "Go_Rush"
    }
    function hello(){            //这个函数为私有函数,仅可以在t.htm内部被调用
    return "hello"
    }
    function public_test(){
    return "test"
    }
    </script>
    </html>
    test.htm------------------------------------
    <body>
    <object id="mm" data="t.htm" type="text/x-scriptlet" VIEWASTEXT></object>
    </body>
    <script defer>
    function f(){
      alert(mm.getname())
      alert(mm.test())
       try{      //这里mm.hello() 会失败
          alert(mm.hello())
      }catch(x){}
    }
    f()
    </script>
      

  4.   

    try{     
          alert(mm.hello())
      }catch(x){alert("调用mm.hello()失败")}
      

  5.   

    当然,如果你只是想在 scriptlet里面定义公用变量,更简单t.htm<script>var public_vv="www.csdn.net";</script>
    test.htm<object id="mm" data="t.htm" type="text/x-scriptlet" VIEWASTEXT></object>
    <script defer>alert(mm.vv)</script>