IE8 模态窗口解决方案

解决IE8下模态窗口打开时又重新打开新窗口

1、A页面打开模式窗口B    HTML 部分

<HEAD>
  <title>EC_Kslb</title>
  <script>function cwin()
   {
    {
    var a=document.all("txtcFBM").value;
    var fbm=window.showModalDialog('001.html',a,'dialogWidth:220px;dialogHeight:350px;center:yes;status:no');
    if(fbm!=null)
    {
   document.all("txtcFBM").value=fbm;
    }
   }
   }
  </script>
 </HEAD>

2、A页面打开模式窗口B   代码部分

imports system.text  '引用

 Public Shared Sub CallJavaScript(ByVal page As Page, ByVal FunName As String)
        Dim StrScript As New StringBuilder
        StrScript.Append("<script language=javascript>")
        StrScript.Append(FunName)
        StrScript.Append(";")
        StrScript.Append("</script>")
        If Not page.IsStartupScriptRegistered("Call" & FunName) Then
            page.RegisterStartupScript("Call" & FunName, StrScript.ToString())
        End If
    End Sub

 Private Sub imgselectcd_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgselectcd.Click

'可在此加入值进行传值,修改js代码动态传值
        CallJavaScript(Me, "cwin()")
    End Sub

3、001.html代码嵌入框架

<iframe name="god" src="selKslb.aspx" frameborder="0" height="400px" width="600px"></iframe>
4、selKslb.aspx代码部分

HTML部分

<HEAD>
  <title>selKslb</title>
  <base target="_self">
 </HEAD>

 

代码部分

 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
         Context.Response.Cache.SetCacheability(HttpCacheability.NoCache)
          If Not IsPostBack Then
        End If
    End Sub

按钮按下后返回值

   Response.Write("<Script language='JavaScript'>window.parent.returnValue='" & temp & "';</script>")
        Response.Write("<Script language='JavaScript'>window.opener=null;window.open('','_self');window.close();</script>")

你可能感兴趣的:(JavaScript,html,框架,String,iframe,IE)