尝试在新窗口中打印内容

用户名

我正在尝试print将htmlcontents转换为new window

var w= window.open();
var htmlContent = $(printdiv).html(printcontent);
$(w.document.body).html(htmlContent);
$(w).location.reload();
$(w).focus();
$(w).print();
$(w).close();

我得到一个blank window没有html内容的代替品吗?

来宾271314

尝试设置新的window名称引用,除去$()周围的包装w.focus().print().close()因为jQuery()没有方法.print()调用.print()链接到$()将返回TypeError: undefined is not a function

// set `w` name reference
var w = window.open("", "w");
var htmlContent = $(printdiv).html(printcontent);
$(w.document.body).html(htmlContent);
// $(w).location.reload();
w.focus();
w.print();
w.close();

jsfiddle http://jsfiddle.net/14f5owux/

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章