javascript - Chrome: window.print vs ctrl + p - Stack Overflow

I have a internet project where users print a lot. So we add "print button" in every page.It

I have a internet project where users print a lot. So we add "print button" in every page.

It work's fine in all browser, but google chrome.

This button just call "javacript:window.print". But when pressed, chrome opens new tab "chrome://print" just like when CTRL+P is typed.

But with CTRL+P print preview is showed fine. With "window.print" we get this message: "Print is unavailable because the page you were trying to print has been closed."

How can I solve this?

I have a internet project where users print a lot. So we add "print button" in every page.

It work's fine in all browser, but google chrome.

This button just call "javacript:window.print". But when pressed, chrome opens new tab "chrome://print" just like when CTRL+P is typed.

But with CTRL+P print preview is showed fine. With "window.print" we get this message: "Print is unavailable because the page you were trying to print has been closed."

How can I solve this?

Share Improve this question edited Oct 27, 2017 at 10:11 Mwiza 9,1213 gold badges52 silver badges44 bronze badges asked Oct 28, 2011 at 12:02 ZoteZote 5,3795 gold badges43 silver badges43 bronze badges 1
  • Do you have a test case? It seems to work fine on jsfiddle/pimvdb/V8nWZ. – pimvdb Commented Oct 28, 2011 at 12:05
Add a ment  | 

1 Answer 1

Reset to default 5

Try to add a "return false;" to the button to prevent the default action. So it opens the new tab, but keep the old one at the previous state.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745303274a4621565.html

相关推荐

  • javascript - Chrome: window.print vs ctrl + p - Stack Overflow

    I have a internet project where users print a lot. So we add "print button" in every page.It

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信