Javascript Google Crome和Firefox浏览器中的打印问题

Javascript Google Crome和Firefox浏览器中的打印问题,javascript,google-chrome,firefox,printing,Javascript,Google Chrome,Firefox,Printing,我使用的是javascript浏览器的打印功能。这是我以前做的 BindPrintPubReport: function () { //Printed by Values. var username = "Sanjeev"; //End. var htmltags = ''; htmltags += '<h3 style="margin: 1

我使用的是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.

        }

//开始
docprint.document.write($(窗口).load(函数(){docprint.print();docprint.close();}););
//结束。

它可以在GoogleCrome中加载图像,但在Firefox中打印不起作用。正如我提到的,打印操作不正常。我应该如何在所有浏览器中提供支持?

我已更改代码:

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

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

//start
   docprint.document.write("<script>$(window).load(function(){       docprint.print();docprint.close(); });</script>");
            //end.
 //Start 
 docprint.focus();
 docprint.print();
 docprint.close();
 //end.
  $(docprint).ready(function () {
                setTimeout(
                  function () {
                      docprint.focus();
                      docprint.print();
                      docprint.close();
                  }, (1000));
            });