Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 铬:不';不打印javascript内容_Jquery_Google Chrome_Printing_Greasemonkey_Tampermonkey - Fatal编程技术网

Jquery 铬:不';不打印javascript内容

Jquery 铬:不';不打印javascript内容,jquery,google-chrome,printing,greasemonkey,tampermonkey,Jquery,Google Chrome,Printing,Greasemonkey,Tampermonkey,(这是通过润滑脂/捣固机进行的) 以下是使用Chrome beta浏览器的信息亭打印功能: $("#autoCheckOrder button").click ( function () { var newWin = window.open (""); newWin.document.write ( "<!DOCTYPE html>" ); newWin.document.write( "<html>" ); newWin.do

(这是通过润滑脂/捣固机进行的)

以下是使用Chrome beta浏览器的信息亭打印功能:

$("#autoCheckOrder button").click ( function () {
    var newWin      = window.open (""); 
    newWin.document.write ( "<!DOCTYPE html>" );
    newWin.document.write( "<html>" );
    newWin.document.write( "<head>" );
    newWin.document.write( "<title>" );
    newWin.document.write( "</title>" );
    newWin.document.write( "<style>" );
    newWin.document.write( "@media print { " );
    newWin.document.write( "body { " );
    newWin.document.write( "background-color: white;" );
    newWin.document.write( "width: 55mm;" );
    newWin.document.write( "position: absolute;" );
    newWin.document.write( "top: 0;" );
    newWin.document.write( "left: 0;" );
    newWin.document.write( "padding: 0px;" );
    newWin.document.write( "font-size: 14px;" );
    newWin.document.write( "line-height: 18px;" );
    newWin.document.write( "}" );
    newWin.document.write( "}" );
    newWin.document.write( "</style>" );
    newWin.document.write( "</head>" );
    newWin.document.write( "<body>" );
    newWin.document.write ( loanHTML ); 
    newWin.document.write( "</body>" );
    newWin.document.write( "</html>" );
    if(newWin.print()) {
        newWin.close();
    } else {
        newWin.close();
    }
});
$(“#自动检查按钮”)。单击(功能(){
var newWin=window.open(“”);
newWin.document.write(“”);
newWin.document.write(“”);
newWin.document.write(“”);
newWin.document.write(“”);
newWin.document.write(“”);
newWin.document.write(“”);
newWin.document.write(“@media print{”);
newWin.document.write(“body{”);
newWin.document.write(“背景色:白色;”);
newWin.document.write(“宽度:55mm;”);
newWin.document.write(“位置:绝对;”);
newWin.document.write(“top:0;”);
newWin.document.write(“左:0;”);
newWin.document.write(“padding:0px;”);
newWin.document.write(“字体大小:14px;”);
newWin.document.write(“行高:18px;”);
newWin.document.write(“}”);
newWin.document.write(“}”);
newWin.document.write(“”);
newWin.document.write(“”);
newWin.document.write(“”);
newWin.document.write(loanHTML);
newWin.document.write(“”);
newWin.document.write(“”);
if(newWin.print()){
newWin.close();
}否则{
newWin.close();
}
});
它从a页面获取一个列出所有项目的表,然后创建一个 “收据”。然后打印收据。这在一段时间内效果很好,现在它只打印第一个项目

我尝试了以下方法,但毫无结果:

  • 使用分页符后:始终
  • 使用上述CSS规则将收据放入div
  • 重新安装打印机
  • 打印机的纸张缩减设置
疯狂的是,它曾经完美地打印所有项目,而现在它没有了。我甚至从备份中重新安装了脚本以确保安全

不知道从这里到哪里去。所有内容都显示在打印预览中,但仅打印第一项。”页眉和页脚的设置只会让事情变得更糟,而不是更好

更新


我更改了发送到打印机的HTML,它可以正常工作。仍然不确定它是否完全有效,但它正在打印。如果它停止打印,我就知道该修复什么了。谢谢你的意见

我能看到的唯一合理的解释是loanHTML变量为空或未定义

演示:


注释掉
var loanHTML
行并再次运行,您就会明白我的意思。

我能看到的唯一合理解释是您的loanHTML变量为空或未定义

演示:


注释掉
var loanHTML
行,然后再次运行,你就会明白我的意思了。

为什么要在JavaScript中这样做。这是错误的,别无选择。第三方内部应用程序。你为什么要用JavaScript来做这件事。这是错误的,别无选择。第三方内部应用程序。它在Greasemonkey/Firefox中工作。这是一个表格,出于某种原因,只有第一行在Chrome中打印,尽管整个内容显示在打印预览中。想知道在写入收据页面之前是否应该将整个内容写入页面上的隐藏div。实际上,
loanHTML
可能格式不正确。FF和Chrome处理格式错误的代码的方式不同,Chrome“字符串化”的方式也不同。将出现故障的打印页保存到光盘。然后用Chrome打开该文件并验证它(仍然)存在问题。重复此操作,直到演示文件出现问题。然后将该文件上载到并指向。。。还有,
loanHTML
是如何定义/设置的?我想你肯定知道了一些事情。div从表内拉出,从而剥离表外标签。我并没有为此做任何事,因为它似乎工作得很好……起初……然后很快就忘记了那个小细节。仍然想知道为什么它一开始就有效。Brock Adams~是的,无效的html。现在工作。谢谢它在Greasemonkey/Firefox中工作。这是一个表格,出于某种原因,只有第一行在Chrome中打印,尽管整个内容显示在打印预览中。想知道在写入收据页面之前是否应该将整个内容写入页面上的隐藏div。实际上,
loanHTML
可能格式不正确。FF和Chrome处理格式错误的代码的方式不同,Chrome“字符串化”的方式也不同。将出现故障的打印页保存到光盘。然后用Chrome打开该文件并验证它(仍然)存在问题。重复此操作,直到演示文件出现问题。然后将该文件上载到并指向。。。还有,
loanHTML
是如何定义/设置的?我想你肯定知道了一些事情。div从表内拉出,从而剥离表外标签。我并没有为此做任何事,因为它似乎工作得很好……起初……然后很快就忘记了那个小细节。仍然想知道为什么它一开始就有效。Brock Adams~是的,无效的html。现在工作。谢谢