PrintThis Jquery plugin issue in Google Chroome

十年热恋 提交于 2019-12-25 02:38:10

问题


I am using Jquery plugin PrintThis.js and jquery-1.7.2.min.js to print a specific div of my web page. It works fine in Firfox and IE. But unfortunately its not working on Google Chrome. Actually Google Chrome is printing Complete web page including the Banner, Menus, and buttons as well. I Searched alot on net but unable to get a suitable solution

Here is my sample code

Java Script

$(function () { 
$("input:button").click(function () {
$("#print").printThis();
});
});

HTML

<body>
<input type="button" value="print" />
<div id="print">
this is print area, it can be everything. this is print area, it can be everything.this is print area, it can be everything. this is print area, it can be everything.
</div>
</body>

Here in this page in Google Chroome the button will also be printed, But i dont want this button to be printed, and the same code works fine in Firefox and surprisingly in IE it is also working fine


回答1:


I find the following code to work with my chrome installation (version 32.0.1700.102 m) and printThis v1.3.

JS:

$(function () { 
$("input:button").click(function () {
$("#print").printThis();
});
});

HTML:

<body>
<input type="button" value="print" />
<div id="print">
this is print area, it can be everything. this is print area, it can be everything.this is print area, it can be everything. this is print area, it can be everything.
</div>
</body>

Here's a fiddle where I receive the successful result: http://jsfiddle.net/NetsydeMiro/dS6qK/

Perhaps it's an issue with the version of printThis that you're using?

Let me know if this fiddle works for you.



来源:https://stackoverflow.com/questions/21477200/printthis-jquery-plugin-issue-in-google-chroome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!