在新选项卡中打开Pdf
本文关键字:Pdf 新选项 选项 | 更新日期: 2023-09-27 18:05:44
On Button Click我生成一个PDF文件,然后在客户端打开它:
Response.ContentType = "application/pdf";
Response.TransmitFile(path);
这将在浏览器中显示pdf,但在相同的选项卡中。如何在新标签页中打开它?
<%@ 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>
您不能从服务器端执行此操作。这是一个客户端操作。参见从ASP为网页创建新选项卡或窗口。净