在新视窗中开启档案

编程入门 行业动态 更新时间:2024-10-24 12:30:03
本文介绍了在新视窗中开启档案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 作为我上一篇文章的解决方案," 文件未打开. [ ^ ] 我发现此代码打开了我想要的pdf文件,但是我想要在新页面中打开它? 我的代码是;

Hello all, As a solution to my previous post ""Files are not opening.[^] I found this code which opens the pdf file that I want but what I want is to open this in a new page? My code is;

string fileToRenamePath = RMAConfig.PDFPath + "Return Documentation [ " + this.rmaObjSum.RMANum + " ]" + RMAConfig.Extension; // The valeu for fileToRenamePath here is : C:/RMA/Returns/Return Documentation[3232-32326].pdf WebClient client = new WebClient(); Byte[] buffer = client.DownloadData(fileToRenamePath); if (buffer != null) { Response.ContentType = "application/pdf"; Response.AddHeader("content-length", buffer.Length.ToString()); Response.BinaryWrite(buffer); }

这将在当前浏览器中打开文件.

This open the file in the current browser.

推荐答案

这可能有用. This might work. Response.Write("<script>window.open('file.pdf',target='new');</script>")

编辑================ 好吧,我放弃.为什么要进行1票表决?

EDIT ================ Okay, I give up. Why was this 1-voted?

U可以使用target = _blank属性,将其作为新窗口打开 EG: Hi, U can Use target=_blank property which will open it as new window EG: Response.Write("<script>window.open(''www.google.hk/'',''_blank'');</script>");

快乐编码

Happy Coding

更多推荐

在新视窗中开启档案

本文发布于:2023-10-24 17:18:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524537.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:档案   窗中   新视

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!