如何使用javascript在winForm中单击按钮时打开pdf文件?

如何使用javascript在winForm中单击按钮时打开pdf文件?

问题描述:


我在"C"文件夹中创建了一个PDF文件.

当用户单击按钮"时,我要打开该"PDF文件".


请帮助我..

Hi
i created one PDF file in my "C" Folder.

when the user click on "button", i want to open that "PDF file".


Please help me..

用两行代码完成,前提是您的计算机上安装了acrobat阅读器. System.Diagnostics命名空间具有一个用于执行此操作的流程类.

添加
Well in 2 lines of code you can do that assuming you have acrobat reader installed in your computer. System.Diagnostics namespace has a process class to do this.

add
using System.Diagnostics;




将此代码放在您的按钮单击事件中.




Place this code to your button click event.

string pdfFileName = "C:\\mypdfFileName.pdf";
System.Diagnostics.Process.Start(pdfFileName);



c#.net;



c#.net;

Response.Write("<SCRIPT language=javascript>var pdf=window.open('" +
result + "','PDF');pdf.moveTo(0,0);</SCRIPT>");







or

<script type="text/javascript">
function openWindow(path)
{
var myWin = window.open(' " + pdfFileName + " ','mywindow','width=400,height=200');
}
</script>
...
<input type="button" onClick="openWindow(varName)">