在b.htm
加上:
<script>
  function1('a'); 
</script>
function在前面定义好。。
反正就是打开b.htm时执行function1('a')就行了

解决方案 »

  1.   

    我看在于你怎么定义了,象下面这样;
    <SCRIPT LANGUAGE="JavaScript"><!-- 
    function fullSize(sURL){window.open(sURL,'scrshot','width=500,height=375,top=20,left=20,directories=no , Toolbar = no, resizable = yes, menubar = no, ScrollBars = yes ');
    }
    --></SCRIPT><A HREF="javascript:fullSize('f01og01x.htm')"> <img src="f01og01.jpg" width=404 height=362 border=0 ALT = "Click to view at full size.">
      

  2.   

    在b.htm没有载入之前,你是访问不到里面定义的函数的。
    为什么非要这样做呢?说说你的具体需求。
      

  3.   

    在b.htm中添加
    <body onload="javascript:function1('a')">
      

  4.   

    to yousoft(悠游在线):
    能否说详细些?
      

  5.   

    同时要保证在B.htm文件中定义的javascript函数---function1('a')要放到
    B.HTM页面中<BODY>标签的前面.
      

  6.   

    to ahphone(阿丰):
    给个实例吧
      

  7.   

    to all:
    我希望b.htm这个页面在被其它页面链接的情况下不调用function1这个函数,只有在被a.htm这个页面链接时才调用b.htm中的function1这个函数。
      

  8.   

    <!--a.htm-->
    <html>
    <a href='b.htm'>b.htm</a>
    </html><!--b.htm-->
    <html>
    <script>
    function function1() {
      if(!/\/a\.htm$/i.test(document.referrer)) {
        return;
      }
      // add your codes here ...
    }window.onload = function1;
    </script>
    </html>
      

  9.   

    to huntout(猎手):
    看了你的方法,对我的问题很有启发意义那么请问大家:
    a.htm该怎么通过链接传一个参数给b.htm,而b.htm又该怎么得到这个参数呢?
      

  10.   

    <!--a.htm-->
    <html>
    <form action='b.htm?a=1' method=post>
    </form>
    <a href='javascript:document.forms[0].submit'>b.htm</a>
    </html><!--b.htm-->
    <html>
    <script>
    function function1() {
      if(!/\/a\.htm$/i.test(document.referrer)) {
        return;
      }
      alert(window.location.search);
      // add your codes here ...
    }window.onload = function1;
    </script>
    </html>
      

  11.   

    我的a.htm按照你的方法做过以后,点击链接后显示
    function submit() {
        [native code]
    }请问何故?
      

  12.   

    to huntout(猎手):
    我的a.htm按照你的方法做过以后,点击链接后显示
    function submit() {
        [native code]
    }很奇怪,请问何故?还有在b.htm中怎么得到a.htm传的变量a的值呢?
      

  13.   

    谢谢各位,我已经找到答案了特别感谢:huntout(猎手)