我正在尝试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
内容的代替品吗?
尝试设置新的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] 删除。
我来说两句