Javascript 在新浏览器全窗口中打开 PDF
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4735968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Open PDF in new browser full window
提问by mojeime
How do I open PDF document in new browser window?
如何在新的浏览器窗口中打开 PDF 文档?
The window should be full and withouth menu.
窗口应该是完整的并且没有菜单。
Just a PDF document in a clean full window with native Javascript or jQuery.
只是一个带有原生 Javascript 或 jQuery 的干净的完整窗口中的 PDF 文档。
回答by Shadow Wizard is Ear For You
<a href="#" onclick="window.open('MyPDF.pdf', '_blank', 'fullscreen=yes'); return false;">MyPDF</a>
The above link will open the PDF in full screen mode, that's the best you can achieve.
上面的链接将以全屏模式打开 PDF,这是您可以实现的最佳方式。
回答by BlackMagic
var pdf = MyPdf.pdf;
window.open(pdf);
This will open the pdf document in a full window from JavaScript
这将在一个完整的窗口中打开 pdf 文档 JavaScript
A function to open windows would look like this:
打开窗口的函数如下所示:
function openPDF(pdf){
window.open(pdf);
return false;
}
回答by paxdiablo
I'm going to take a chance here and actually advise against this. I suspect that people wanting to view your PDFs will already have their viewers set up the way they want, and will not take kindly to you taking that choice away from them :-)
我要在这里碰碰运气,实际上建议不要这样做。我怀疑想要查看您的 PDF 的人们已经按照他们想要的方式设置了他们的查看器,并且不会善待您从他们那里拿走这个选择:-)
Why not just stream down the content with the correct content specifier?
为什么不直接使用正确的内容说明符向下传输内容?
That way, newbies will get whatever their browser developer has a a useful default, and those of us that know how to configure such things will see it as we want to.
这样,新手将获得他们的浏览器开发人员拥有的任何有用的默认值,而我们这些知道如何配置这些东西的人将按照我们的意愿看到它。