在IE中,标题中提到的Ajax 的运用中如果有frame元素那么则会出错

比如:

<ajaxToolkit:ModalPopupExtender ID="ModalPopupShowDealDetail" runat="server"
         TargetControlID="HiddenShowDealDetail" DropShadow="true" PopupControlID="PanelShowDealDetail"
         BackgroundCssClass="modalBackground" Y="20" CancelControlID="ImageButtonClose" PopupDragHandleControlID="PanelTitle">
      </ajaxToolkit:ModalPopupExtender>
      <input id="HiddenShowDealDetail" type="hidden" runat="server" />
      <asp:Panel ID="PanelShowDealDetail" Style="display: none" CssClass="modalPopup"
         runat="server" Height="550px" Width="700px">
         <asp:Panel ID="PanelTitle" runat="server" CssClass="popupTitlePanle">
           <span style="float:right">
              <asp:ImageButton ID="ImageButtonClose" Width="20px" ImageUrl="~/Images/BillDealFlow/error.gif" runat="server" ToolTip="关闭" /></span><span id="popupTitle"></span>
         </asp:Panel>
         <div id="iframeContainer">
         </div>
      </asp:Panel>

如果我在红色的div内部加入一个iframe元素

<div id="iframeContainer"><iframe />
   </div>

那么整个Ajax的加载就会出错

解决的访问是等页面加载完通过Javascript为div创建iframe元素就不会出错了

function openPopup(popupId,url,title,titleId,iwidth,iheight,containerId)
      {
      var p=$find(popupId);
      var d=$get(containerId);
      var t=$get(titleId);
      if(t!=null)
      {
      t.innerText=title;
      }
      var iframes=d.getElementsByTagName('iframe');
      if(iframes!=null)
      {
      for(var i=0; i<iframes.length;i++)
      {
      d.removeChild(iframes[i]);
      }
      }
      var iframe=document.createElement('iframe');
      iframe.src=url;
      d.appendChild(iframe);
     
      if(p!=null)
      {
      if(iframe!=null)
      {
      iframe.src=url;
      iframe.border=0;
      iframe.frameBorder=0;
      iframe.scrolling="no";
      iframe.marginwidth=0;
      iframe.style.width=iwidth;
      iframe.style.height=iheight+'px';
      p.show();
      return true;
      }
      }
      return false;
      }
      </script>

类似的问题还会出现在xslt中


About author
Disclaimer
The opinions and comments expressed herein are my own personal opinions and do not represent my employer's view in any way.
Comments
No comments.
Add comment
Title
Title is required.
Name
Name is required.
Email
Please input your personal email with valid format.
Comments
Please input comment content.
Captcha Refresh
Input captcha:

Subscription

Statistics

Locations of visitors to this page