2

このコードを使用して、ポップアップからpdfファイルをエクスポートしています。

ボタンをクリックすると

  function popupReport() 
    {
        var url = 'Report.aspx';
        window.open(url, 'winPopupReport', 'width=300,height=300,resizable=no,scrollbars=no,toolbar=no,directories=no,status=no,menubar=no,copyhistory=no');
        return false;
    }

およびReport.aspx.cs

 ReportDocument repDoc = ( ReportDocument ) System.Web.HttpContext.Current.Session["StudyReportCrystalDocument"];
        // Stop buffering the response
        Response.Buffer = false;
        // Clear the response content and headers
        Response.ClearContent();
        Response.ClearHeaders();
        try
        {
            repDoc.ExportToHttpResponse( CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "StudyReport" );
        }
        catch( Exception ex )
        {
        }

コードはIE7で正常に機能します。しかし、IE6ではポップアップウィンドウが閉じていません。なぜこれが起こったのですか?

4

1 に答える 1

0

一部のブラウザは、特定の条件で Web ページの自動終了を拒否します。

ページを閉じるには、この回避策を試してください。

閉じたいページに、別のページを開くスクリプトを記述します。このサンプルでは、​​スクリプトはボタンのクリック後にコードを介して挿入されますが、必要に応じて HTML で直接記述できます。

   ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.open('Success.htm', '_self', null);", true);

この方法で Success.htm ページを作成します

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head>
  <title></title>
  <script language="javascript" type="text/javascript">
   var redirectTimerId = 0;
   function closeWindow() {
      window.opener = top;
      redirectTimerId = window.setTimeout('redirect()', 2000);
      window.close();
  }

  function stopRedirect() {
     window.clearTimeout(redirectTimerId);
 }

  function redirect() {
     window.location = 'default.aspx';
 }
 </script>
</head>
<body onload="closeWindow()" onunload="stopRedirect()" style="">
   <center><h1>Please Wait...</h1></center>
</body></html>
于 2012-02-24T10:42:46.250 に答える