问题描述
我正在使用Jquery插件PrintThis.js和jquery-1.7.2.min.js来打印我的网页的特定div.它在Firfox和IE中工作正常.但不幸的是,它不能在谷歌浏览器上运行.实际上,谷歌浏览器正在打印完整的网页,包括横幅,菜单和按钮.我在网上搜索了很多,但无法找到合适的解决方案
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
这是我的示例代码
Java脚本
$(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>
在此页面中,Google Chroome的按钮也将被打印,但是我不希望该按钮被打印,并且相同的代码在Firefox中可以正常工作,而令人惊讶的是,在IE中它也可以正常工作
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
推荐答案
我发现以下代码可用于我的Chrome安装(版本32.0.1700.102 m)和printThis v1.3.
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>
以下是我收到成功结果的小提琴: http://jsfiddle.net/NetsydeMiro/dS6qK/
Here's a fiddle where I receive the successful result: http://jsfiddle.net/NetsydeMiro/dS6qK/
也许您使用的printThis版本有问题?
Perhaps it's an issue with the version of printThis that you're using?
让我知道这个小提琴是否对您有用.
Let me know if this fiddle works for you.
这篇关于Google Chroome中的PrintThis Jquery插件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!