我正在使用Jquery插件PrintThis.js和jquery-1.7.2.min.js打印我的网页的特定div。它在Firfox和IE中运行良好。但不幸的是,它不能在Google Chrome上运行。实际上,Google Chrome正在打印完整的网页,包括横幅、菜单和按钮。我在网上找了很久,也没找到合适的解决方案。
下面是我的示例代码
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中也能正常工作
发布于 2014-01-31 19:00:12
我发现以下代码适用于我的chrome安装(版本32.0.1700.102m)和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/
也许是你使用的printThis版本有问题?
如果这把小提琴对你有效,请告诉我。
https://stackoverflow.com/questions/21477200
复制相似问题