2009-06-10 40 views
2

私はこのコードを使用して、pdfファイルをポップアップからエクスポートしています。ASP.NETでのCrystalレポートの問題 - ExportToHttpResponse

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では、ポップアップウィンドウが閉じていません。なぜこれが起こったのですか?

答えて

0

一部のブラウザでは、一部の条件下でウェブページの自動クローズを拒否しています。

ページを閉じるにはこのワークアラウンドをお試しください。

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

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

このよう

<!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> 
Success.htmページを作成します。
関連する問題