【问题标题】:Open Pdf in new tab在新标签页中打开 PDF
【发布时间】:2011-08-17 08:40:00
【问题描述】:

在按钮上单击我生成一个 PDF 文件,然后在客户端打开它:

Response.ContentType = "application/pdf";
Response.TransmitFile(path);

这将在浏览器中显示 pdf,但在同一选项卡中。如何在新标签页中打开它?

【问题讨论】:

  • 查看this 博文。

标签: c# asp.net pdf


【解决方案1】:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script  language=vbscript>
sub OpenInNewWindow()
    window.open("PDFContainer.aspx")
end sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Way 3</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type=button OnClick="OpenInNewWindow()"  value="Open in New Window"/>
        <br /><br />
        This time, we will open a new Internet Explorer Window and Show the PDF File directly in the IE
    </div>
    </form>
</body>
</html>

【讨论】:

  • +1 只是为了看到客户端 VBScript 的难得体验
【解决方案2】:

您不能从服务器端执行此操作。这是一个客户端操作。见Create a new tab or window for a web page from ASP.NET

【讨论】:

    猜你喜欢
    • 2016-10-21
    • 1970-01-01
    • 2014-03-26
    • 2016-12-23
    • 2020-05-31
    • 2019-12-28
    • 2016-03-24
    • 1970-01-01
    • 2012-05-09
    相关资源
    最近更新 更多