藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年8月25日 8:28

求教JS調用IFRAME頁面的JS方法

我的網頁中有個IFRAME,我想在本頁用JS調用IFRAME頁面的JS方法,有沒有辦法啊,高手們!
<DIV id="div_FHXX" title="卸貨信息" runat="server"><iframe id="FrameRS" onfocus="frmFocus('FrameRS')" name="FrameRS" marginWidth="0" marginHeight="0"
                                                                src="LandRS.aspx" frameBorder="no" width="100%" scrolling="no" height="100%" runat="server"></iframe>
                                                </DIV>
<script>
      
                    function Apply_SHEdit()
                    {
                             document.getElementById('FrameRS').ApplySHEdit();
                    }
                  
                        </script> :o

把document.getElementById("FrameRs").ApplySHEdit();
換成:
FrameRS.ApplySHEdit();
試試。
舉例如下:
aa.htm
[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=utf-8">
<title>Untitled Document</title>
</head>

<body>
<p>
  <input type="button" name="Button" value="Button" onclick="addRow()">
  <input type="button" name="Button" value="Button" onclick="delRow()">
</p>
<iframe id="ifr" width="100%" height="300" scrolling="auto" src="bb.htm"></iframe>
</body>
</html>
<script language="javascript">
function addRow(){
        ifr.addRow();
}
function delRow(){
        ifr.delRow();
}
</script>
[/html]
bb.htm
[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=utf-8">
<title>Untitled Document</title>
</head>

<body>
<p>
  <input type="button" name="Button" value="addRow" onclick="addRow()">
  <input type="button" name="Button" value="deleteRow" onclick="delRow()">
</p>
<table width="100%"  border="1" cellpadding="2" cellspacing="2" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF" id="tab1">
  <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
  </tr>
</table></body>
</html>
<script language="javascript">
oTab=document.getElementById("tab1");
function addRow(){
        var oTr=oTab.insertRow();
        var cols=oTab.rows[0].cells.length;//得到表格有幾列。
        //alert(cols);
        for(var i=0;i<cols;i++){
                var oTd=document.createElement("TD");
                oTd.innerHTML=i+1;
                oTr.appendChild(oTd);
        }
}
function delRow(){
        var rows=oTab.rows.length;
        if(rows<=1) return false;
        var oTr=oTab.rows[rows-1];
        oTab.deleteRow(oTr)
}
</script>
[/html]
IE6下運行通過。
FireFox不支持這樣做,




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com