Html 如何使用打印命令打开链接新标签?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12276416/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:39:47  来源:igfitidea点击:

How to open a link new tab with print command?

htmlprintinghyperlink

提问by Sandy

I have a hyperlink with contains third party website link. I want to open this link in new tab with print command. How can i do this? Suppose:

我有一个包含第三方网站链接的超链接。我想使用打印命令在新选项卡中打开此链接。我怎样才能做到这一点? 认为:

<a href="www.google.com" target="_blank">Print</a>

Note: I know how to open a link in new TAB/Window. I want to know how to open with PRINT DIALOG.

注意:我知道如何在新选项卡/窗口中打开链接。我想知道如何用 PRINT DIALOG 打开。

回答by Nikola

You could try something like this:

你可以尝试这样的事情:

<a href="javascript: w=window.open('http://yoursite.com/LinkToThePDF.pdf'); w.print(); w.close(); ">?????????????????print pdf</a>

回答by Vitalicus

<img src="print.png" style="cursor:hand" onclick="window.frames['pact'].print();"><iframe name="pact" src="pact.pdf" width="0" height="0" frameborder="0"></iframe>

回答by Collin Anderson

This method works well for me.

这种方法对我很有效。

<a href="/url/" onclick="open(this.href).print(); return false">

回答by Quentin

There is no way for a website to cause a browser to load a third party website anddisplay the print dialog for it automatically.

网站无法让浏览器加载第三方网站自动为其显示打印对话框。

回答by Mr. Benedict

This absolutely worked for me. I'm coding a site in Angular 6.

这绝对对我有用。我正在用 Angular 6 编写一个站点。

<a href="doc.pdf" onClick="window.print(); return false">Print</a>

Here's my source (enter link description here) but watch out for double quotes in the originak source.

这是我的来源(在此处输入链接描述)但要注意 originak 来源中的双引号。

:)

:)

回答by Sujanth

This is depend on your browsers, you can enable the tab for new link, If you are using Firefox you can enable the tab using Firefox -> Options -> options -> open a new windows in a new tab insteadoption

这取决于你的浏览器,您可以启用新的链接选项卡,如果您使用的是Firefox,你可以使用启用选项卡中的Firefox - >选项- >选项- >在新标签中打开一个新的窗口,而不是选项