最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Alternative to Window.Print() - Stack Overflow

programmeradmin5浏览0评论

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');
发布评论

评论列表(0)

  1. 暂无评论