admin管理员组

文章数量:1333210

I want to create a print button so that when it is pressed, it prints the whole webpage. I am currently using Window.print() of javascript. But I ran into error; when ever i press the print button more than once, the link stops working. What is the problem with it ? Is there an alternative to this in jquery or any other ? I am using grails 1.3.7. Thanks

I want to create a print button so that when it is pressed, it prints the whole webpage. I am currently using Window.print() of javascript. But I ran into error; when ever i press the print button more than once, the link stops working. What is the problem with it ? Is there an alternative to this in jquery or any other ? I am using grails 1.3.7. Thanks

Share Improve this question asked Apr 17, 2012 at 4:59 Eddard StarkEddard Stark 3,5958 gold badges36 silver badges52 bronze badges 3
  • whatever the problem with it is, it isn't that you are using window.print() (which is the only way to get the browser to print something without using its native UI). – Quentin Commented Apr 17, 2012 at 6:09
  • 2 my wild guess is that you are using chrome and it blocks window.print() if pressed too many times. Check out your javascript console to see if it spits an error or warning. – Hassek Commented Apr 18, 2012 at 22:13
  • 1 Yes i was using chrome, and after your ment I checked it in firefox, it is working fine there. Is there any way in chrome to make this work ? – Eddard Stark Commented Apr 19, 2012 at 4:39
Add a ment  | 

1 Answer 1

Reset to default 4

An alternative way to window.print() is

document.execCommand('print');

本文标签: javascriptAlternative to WindowPrint()Stack Overflow