admin管理员组

文章数量:1419192

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.

本文标签: javascriptChrome windowprint vs ctrlpStack Overflow