假设我在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)
但问题是弹出窗口阻止程序阻止我的新窗口打印页面.
任何人有任何想法?
非常感谢!