【问题标题】:Print Issue in Google Crome and Firefox BrowserGoogle Chrome 和 Firefox 浏览器中的打印问题
【发布时间】:2015-12-02 06:41:00
【问题描述】:

我正在使用使用 javascript 的浏览器的打印功能。这是,我做了什么。

    BindPrintPubReport: function () {
            //Printed by Values.           
            var username = "Sanjeev";
            //End.
            var htmltags = '';
            htmltags += '<h3 style="margin: 10px 0 20px 10px; border-left: 3px solid #4e8ff7; font-size: 23px; padding: 0 10px;">Report Header</h3>';

            htmltags += '<div style="float:left;margin-right:88px;padding-left:10px;margin-top:-20px;">';
            htmltags += '<div><span style="width:120px;display:inline-block;">Generated By : </span>' + username + '</div>'

            //images or logo i want to add in report
            htmltags += '<div style="float:left;margin-right:88px;padding-left:10px;margin-top:-20px;"><img src=http://localhost:1122/images/logo_02.png"/></div>';

          //print document preparation
            var docprint = window.open("", "_blank");
            docprint.document.open();
            docprint.document.write('<html mozNoMarginBoxes><head>');
            docprint.document.write('<style>@page{ margin:45px 10px;}body{font-size:14px;}</style>');
            docprint.document.write('</head><body >'); 
            docprint.document.write(htmltags);
            docprint.document.write('</body></html>');

            //Start 
           docprint.focus();
           docprint.print();
           docprint.close();
           //end.

        }

首先我加载了,它在 google crome 和 firefox 中工作,但在 google crome 图像中没有加载。要在文档中加载图像,我替换代码,`

         //Start 
           docprint.focus();
           docprint.print();
           docprint.close();
           //end.

由,

//start
   docprint.document.write("<script>$(window).load(function(){       docprint.print();docprint.close(); });</script>");
            //end.

它使图像在 google crome 中加载,但在 Firefox 中无法打印。正如我所提到的,打印行为不正常。所有浏览器的支持我该怎么做?

【问题讨论】:

    标签: javascript google-chrome firefox printing


    【解决方案1】:

    我已更改代码:

     //Start 
     docprint.focus();
     docprint.print();
     docprint.close();
     //end.
    

      $(docprint).ready(function () {
                    setTimeout(
                      function () {
                          docprint.focus();
                          docprint.print();
                          docprint.close();
                      }, (1000));
                });
    

    这最终适用于 Firefox 和 Google Chrome 浏览器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-10
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多