主页面index.jsp中有个iframe<table><tr><td>
<iframe id="iframe1" src="load.jsp" height="300" width="355" marginheight="0" scrolling="no">
</td></tr></table>
--------------------------------------------------------------------------------
load.jsp文件的内容是不能修改的,只能在客户端用JS脚本来控制。
load.jsp的内容是这样:<script language="javascript">
function GetMc(text){
必须执行了才能打开连接窗口,内容略过...}
</script><table><tr><td>
<a href="other.jsp" target='_blank' onclick="GetMc('链接');">链接</a>
</td></tr></table>=================================================================================请问
如何才能在打开index.jsp的时候,向load.jsp中添加一段JS脚本,执行点击链接的操作,同时触发GetMc(),并且点击后的窗口仍然在iframe中打开,也就是target='_self'谢谢了!

解决方案 »

  1.   

    不知道什么意思在index.jsp中用类似iframe1.GetMc('你的变量')的试试
      

  2.   

    这样试下.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><body>
    <script type="text/javascript">
    function changeUrl(){
    var frame = document.getElementById("iframe1")
    var doc = frame.contentWindow.document;
    if(typeof doc.readyState == "undefined" || doc.readyState == "complete"){
    frame.onload = onreadystatechange = null;

    var links = doc.getElementsByTagName("a");
    for(var i=0; i<links.length; i++){
    if(links[i].href.indexOf("oter.jsp") >= 0){
    links[i].onclick();
    frame.src = links[i].href;
    }
    }
    }
    }
    </script>
    <table> 
    <tr> 
    <td> </td> 
    <td> 
    <iframe id="iframe1" src="load.jsp" height="300" onload = "changeUrl();" onreadystatechange="changeUrl();" width="355" marginheight="0" scrolling="no"></iframe>
    </td> 
    <td> </td> 
    </tr> 
    </table></body>
    </html>
      

  3.   

    主页面index.jsp中加入onload="setLoadfrm();"function setLoadfrm() {
         window.iframe1.document.getElementsByTagName("a")[0].onclick=window.iframe1.GetMc;
         window.iframe1.document.getElementsByTagName("a")[0].target="_self";
    }