在新标签页中打开PDF [英] Open Pdf in new tab

查看:110
本文介绍了在新标签页中打开PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在按钮上单击我生成PDF文件",然后在客户端使用以下方法打开它:

On Button Click I generate a PDF file and then open it at client side with:

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

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

This will show the pdf in the browser, but in the same tab. How can I open it in a new tab?

推荐答案

<%@ 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>

这篇关于在新标签页中打开PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆