小编tpg*_*lan的帖子

向打印机发送包含HTML代码的javascript变量

假设我在JavaScript中有这样的变量:

var h = "<html><head></head><body><h1>Example</h1><p>This is a variable I want to print to the printer with the browser!</p></body></html>"
Run Code Online (Sandbox Code Playgroud)

如何将此变量的漂亮呈现内容发送到打印机?

我试过了:

var w = window.open();
Run Code Online (Sandbox Code Playgroud)

然后:

$(w).html(h);
Run Code Online (Sandbox Code Playgroud)

然后:

w.print();
Run Code Online (Sandbox Code Playgroud)

但问题是弹出窗口阻止程序阻止我的新窗口打印页面.

任何人有任何想法?

非常感谢!

html javascript printing jquery html5

7
推荐指数
1
解决办法
5890
查看次数

标签 统计

html ×1

html5 ×1

javascript ×1

jquery ×1

printing ×1