【问题标题】:PrintThis Jquery plugin issue in Google ChroomeGoogle Chrome 中的 PrintThis Jquery 插件问题
【发布时间】:2014-01-31 10:01:58
【问题描述】:

我正在使用 Jquery 插件 PrintThis.js 和 jquery-1.7.2.min.js 来打印我网页的特定 div。它在 Firfox 和 IE 中运行良好。但不幸的是,它不适用于 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 中它也运行良好

【问题讨论】:

    标签: javascript html jquery-plugins


    【解决方案1】:

    我发现以下代码适用于我的 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>
    

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

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

    让我知道这个小提琴是否适合你。

    【讨论】:

      猜你喜欢
      • 2014-07-04
      • 1970-01-01
      • 2016-08-24
      • 1970-01-01
      • 1970-01-01
      • 2011-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多