iframe的onload事件在firefox浏览器下不起作用,在IE下正常,代码如下,急求高手指点!谢谢!<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
  CodeFile="organizationIntroduce.aspx.cs" Inherits="organizationIntroduce" Title=" " %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
 <script language="Javascript" type="text/javascript">
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion>=0.1? 16 : 0  function dyniframesize(iframename) {
  var pTar = null;
  if (document.getElementById){
  pTar = document.getElementById(iframename);
  }
  else{
  eval('pTar = ' + iframename + ';');
  }
  if (pTar && !window.opera){
  //begin resizing iframe
  pTar.style.display="block"
    
  if (pTar.contentdocument && pTar.contentdocument.body.offsetHeight){
  //ns6 syntax
  pTar.height = pTar.contentdocument.body.offsetHeight+FFextraHeight;  
  }
  else if (pTar.Document && pTar.Document.body.scrollHeight){
  //ie5+ syntax
  pTar.height = pTar.Document.body.scrollHeight;
  }
  }
}
</script>  <div style="margin-top: 10px;">
  <div style="float: left; width: 30%; height: 600px;background-color:#CCE0FC;">
  <div>
  <h3 style="height: 32px; background-image: url(image/zxxx1.jpg); background-repeat: repeat-x;text-align: center;">
  机构简介
  </h3>
  <ul style="padding-left: 10px; line-height: 25px;">
  <li><a href="yuanBanJianJie.htm" target="riframe">院办简介</a></li>
  <li><a href="yuanBanZhiZhe.htm" target="riframe">院办工作职责</a></li>
  <li><a href="OfficePerson.aspx?type=1" target="riframe">办公室领导</a></li>
  <li><a href="OfficePerson.aspx?type=2" target="riframe">秘书组</a></li>   
    
  </ul>
  </div>
    
  </div>
    
  <div style="float: right; margin-left: 10px; width: 69%; position: relative; height: 600px;">
    
    
  <iframe allowtransparency="true" onload="dyniframesize('riframe');" width="100%"
  frameborder="0" marginwidth="0" marginheight="0" scrolling="no" id="riframe"
  name="riframe" src="yuanBanJianJie.htm">
  </iframe>
  </div>
  </div>
</asp:Content>

解决方案 »

  1.   

    楼主可参考如下方法:main.html 嵌入 iframe.html ,其中iframe.html加载的时候 onload 调用 main.html里的方法:main.html:<!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>
    <script type="text/javascript">
       testBA = function(){
            alert("test");   
       }
    </script>
    </head><body>
    <iframe id="frameA" src="iframe.html" frameborder="0"></iframe>
    </body>
    </html>
    iframe.html:<!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>
    <script type="text/javascript">
      function parentmethod(){
             parent.testBA();
        }
    </script>
    </head><body onload="parentmethod()">
    </body>
    </html>
      

  2.   

    http://d.download.csdn.net/down/3074628/y_h_t
      

  3.   

    问题补充,iframe里的内容动态改变,当内容很大时,IE里可以全部显示,但是在FIREFOX下,只能显示一部分.
      

  4.   

    LZ从哪搞来的code,怎么感觉怪怪的document.getElementById   IE6都支持,还有哪个浏览器需要判断?if (pTar && !window.opera)  这个判断要着干撒?pTar.contentdocument || pTar.Document   通用的pTar.contentWindow.document
      

  5.   

      document.getElementById的判断估计是为了适应WIN98系统下的IE5吧。呵呵!好多年没用过98系统了。