在一个连接中<a href="a.html">连接页面</a>
在a.html页面中有一个函数b();
b()函数是用了判断传入的不同参数来显示本页面中的不同区域部分
-------------------------
现在我想在点击这个 <a href="a.html">连接页面</a>
就执行a.html中的b()请指教

解决方案 »

  1.   

    那直接在 a.html 的 <body onload=b()>
      

  2.   


    是从另一个页面连接到a.html页面中
    根据给函数b()传入不同的参数 显示a.html中的不部分
    ————————总的意思就是点击这个 <a href="a.html">连接页面</a> 
    转到a.html中 我想看到的页面 
      

  3.   


    其实这个思路是可以的啊<a href="a.html?display=显示a">连接页面</a>
    b()中根据传入的参数显示不同的部分。
    不过这个参数LZ要根据你的实际情况要转换一下。
      

  4.   

    在x页面中加入代码 <a  href='/channel/index.html#' onclick='area_overi1(5)>连接报a页面</a> 
    area_overi1(5)函数是根据传入的参数不同 来显示a页面中不同的层内容但结果是 单击“连接报a页面” 页面只转到a页面 并没用调用到 area_overi1(5) 
    怎样做 既转到a页面 又调用到area_overi1(5) 显示相应的内容呢???
      

  5.   

    这样试试:
    x123.html:
    <a href="a.html?id=x123">连接页面</a>a.html:
    <html><head>
    <script>
    var p=location.search.split('=')[1]//得到参数
    function b(){
      switch(p){
        case "x123":
          //do something here........
          break;
        case "x456":
          //do something here........
          break;
        default:
          
      }
    }b();
    </script>
    </head>
      

  6.   

    a.html 在body中加入onload事件,
    如<body onload="javascript:b();">
      

  7.   


    我是在x.html页面中 单击不同的链接 进入到 a.html页面中
    也就是说 单击不同的地方 给b()函数传入不同的值
    如果用这个方法的话 <body onload="javascript:b();">
    能传入不同的值嘛
    又如何确定传入的值
      

  8.   

    var somevalue=window.showModalDialog();
    if(typeof somevalue!='undefined')
    parent.document.getElementById().value=someValue;
    else{
    do somethings
    }
      

  9.   

    5楼代码还没写清楚吗?你给x.html中的各链接不同的参数,然后到a.html中分选不就可以了?
    <a href="a.html?id=x123">链接123</a>
    <a href="a.html?id=x456">链接456</a>

      

  10.   


    你的方法我不是很懂
    我的意思是:在a.html页面中用很多链接<a href="#" onclick="area_overi1(5);">转到5</a>(相当于描点标签) area_overi1(5)函数是确定要在a.html中要显示的模块 。该模块在area_overi1(5)未被调用时为隐藏模块
    ______
    现在我先在另一个页面如:c.html中 调用area_overi1()函数 !!既单击c.html中的一个连接后转到a.html页面中且显示area_overi1()函数所调用的模板 
      

  11.   

    我解释的详细一些,顺便改下代码以容错
    b.html:
    <a href="a.html?id=2">连接页面a.html的2</a>
    c.html:
    <a href="a.html?id=5">连接页面a.html的5</a>a.html:
    <html><head>
    <script>
    function area_overi1(num){
      //your original js code.....
    }//页面加载的时候:
    window.onload=function(){
      var p=location.search  //首先检查URL中的参数(实际应该有,保险起见加判断)
      if(p||p.length>0){     //如果有参数,分解
        p=p.split('=')[1]    //得到参数
        area_overi1(numid);  //执行函数
      }
    }
    </script>
    </head>
    <body>
    <a href="#" onclick="area_overi1(1);">转到1</a>
    <a href="#" onclick="area_overi1(2);">转到2</a>
    <a href="#" onclick="area_overi1(3);">转到3</a>
    <a href="#" onclick="area_overi1(4);">转到4</a>
    <a href="#" onclick="area_overi1(5);">转到5</a>
    </body>
    </html>
      

  12.   

    晕倒,有错。看这个:
    b.html:
    <a href="a.html?id=2">连接页面a.html的2</a>
    c.html:
    <a href="a.html?id=5">连接页面a.html的5</a>a.html:
    <html><head>
    <script>
    function area_overi1(num){
      //your original js code.....
    }window.onload=function(){//页面加载完成后:
      var p=location.search  //首先检查URL中的参数(实际应该有,保险起见加判断)
      if(p||p.length>0){     //如果有参数,分解
        p=p.split('=')[1]    //得到参数
        area_overi1(p);  //执行函数
      }
    }
    </script>
    </head>
    <body>
    <a href="#" onclick="area_overi1(1);">转到1</a>
    <a href="#" onclick="area_overi1(2);">转到2</a>
    <a href="#" onclick="area_overi1(3);">转到3</a>
    <a href="#" onclick="area_overi1(4);">转到4</a>
    <a href="#" onclick="area_overi1(5);">转到5</a>
    </body>
    </html>
      

  13.   

    按你的方法做了
    点击b.html:
    <a href="a.html?id=2">连接页面a.html的2</a>
    只是连接到了a.html页面中
    并没有执行area_overi1()函数
      

  14.   

    不可能吧。你先按我代码做单独测试。成功后再移植进你程序
    <html><head>
    <script>
    function area_overi1(num){
    alert('数字传入了吗?-->'+num)
      //your original js code.....
    }window.onload=function(){//页面加载完成后:
    alert('开始调试')
      var p=location.search  //首先检查URL中的参数(实际应该有,保险起见加判断)
    alert('首先检查URL中的参数:-->'+p)
    alert(p||p.length>0+'是不是true??')
    //如果不是true,把if()判断去掉吧
      if(p||p.length>0){     //如果有参数,分解
        p=p.split('=')[1]    //得到参数
    alert('最终得到:'+p)
        area_overi1(p);  //执行函数
      }
    }</script>
    </head>
    <body>
    <a href="#" onclick="area_overi1(1);">转到1</a>
    <a href="#" onclick="area_overi1(2);">转到2</a>
    <a href="#" onclick="area_overi1(3);">转到3</a>
    <a href="#" onclick="area_overi1(4);">转到4</a>
    <a href="#" onclick="area_overi1(5);">转到5</a>
    </body>
      

  15.   

    alert(p||p.length>0+'是不是true??')
    ---------->说错了,不是true。
    alert(p||p.length>0+'<-----不是空的吧??')//如果不是true,把if()判断去掉吧
      

  16.   


    高手!!!
    把你的代码单独放在网页中执行没问题
    但是加到我的网页中就不行了
    这网页中根本就没执行这个函数  window.onload=function()
    也没弹出'“开始调试”这类的对话框
    但在window.onload=function()函数外面加上alert(“调试……”)能弹出对话框——————
    是不是我的函数放错位置了 还是别的原因!!!!
    ——————————————————————————————
    助人为快乐之本,谢谢你们的帮助!!
      

  17.   

    呵呵,你的页面JS脚本(或是页面引用的JS脚本)里,已经有onload=""之类的东东了!
    例如:<body onload="abc();">检查<body>标签,以及上面提到的脚本里是否已存在onload();
    1、如果存在,就把我的
    alert('开始调试')
      var p=location.search  //首先检查URL中的参数(实际应该有,保险起见加判断)
    alert('首先检查URL中的参数:-->'+p)
    alert(p||p.length>0+'是不是true??')
    //如果不是true,把if()判断去掉吧
      if(p||p.length>0){     //如果有参数,分解
        p=p.split('=')[1]    //得到参数
    alert('最终得到:'+p)
        area_overi1(p);  //执行函数
      }
    合并进去,或者把原来的合并到我的
    window.onload=function(){//页面加载完成后://我的//原来有的代码
    }2、如果没有,砸电脑~~,呵呵
      

  18.   

    高手~~~
    还真有<body onload="abc();">这个
    I 服了 YOU拜谢~~~~~