如何使用jQuery将字符串打印到打印机

时间:2014-07-24 21:52:05

标签: jquery

如何使用jQuery将字符串打印到打印机?

我在页面上有一个打印图标按钮,我想在打印机上打印一个字符串。我该怎么做?

1 个答案:

答案 0 :(得分:0)

我最终使用了printThis.js - https://github.com/jasonday/printThis

// uses jQuery "printThis.js" plugin file and "PrintThis.css" style sheet
function printNotification(printButtonElement, notificationBar) {

    // make copy of div, remove icon, add line breaks after date and then print
    var x = $(printButtonElement).parent().parent().clone();
    x.find("i").remove();
    x.find(".ReportedDate").after("<br\><br\>");
    x.printThis({ loadCSS:"../Content/PrintThis.css"});  // css hides buttons and right aligns the date

    return true;
}