javascript - PrintThis Google Chrome 中的 Jquery 插件问题

标签 javascript html jquery-plugins

我正在使用 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 中它也工作正常

最佳答案

我发现以下代码适用于我的 chrome 安装(版本 32.0.1700.102 m)和 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>

这是我收到成功结果的 fiddle : http://jsfiddle.net/NetsydeMiro/dS6qK/

也许是您使用的 printThis 版本有问题?

让我知道这个 fiddle 是否适合您。

关于javascript - PrintThis Google Chrome 中的 Jquery 插件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21477200/

相关文章:

javascript - @font-face、Firefox、CDN、document.domain

javascript - 异步 for 循环行为在 map 和 [].push 之间表现不同

javascript - 将 node-webkit 作为 node.js 应用程序运行

javascript - 为什么 jQuery 找不到这个 react.js 元素?

javascript - 文本内容溢出到较低窗口高度的新动态列

javascript - 检测到更改后自动刷新iFrame

javascript - Youtube 嵌入 API 和外部 JS

javascript - 开发一个返回给定对象的 jQuery 插件,而不是 jQuery 对象本身!

javascript - Jquery 图像裁剪问题 - 显示图像的另一部分而不是选定的

javascript - 使用字形覆盖 bxSlider 自定义前下一个按钮的名称?