在Firefox中打印代码但不在IE中打印

时间:2013-10-06 22:38:22

标签: javascript

我在下面有这个代码。它工作正常并在firefox中打印文档,但它不打印甚至提示在IE中打印文档...

请帮忙......谢谢

<script type="text/javascript">
    function PrintElemm(elem) {
        Popup($(elem).html());
    }
    function Popup(data) {
        var mywindow = window.open('', 'my div', 'height=400,width=600');
        mywindow.document.write('<html><head><title>Print Of - Completed ISO-Request Form</title>');
        mywindow.document.write('</head><body >');
        mywindow.document.write(data);
        mywindow.document.write('</body></html>');

        mywindow.print();
        mywindow.close();
        return true;
    }
</script>

1 个答案:

答案 0 :(得分:1)

Yuppeeeeeeeeeeeees .......这是工作解决方案....对于IE&amp; FireFox两者:-D

<script type="text/javascript">
  function completed()
  {
    var myWindow=window.open('','','width=600,height=400');
    myWindow.document.write("<html><head><title>Workflow System - Rejected Request Form</title></head>");
    myWindow.document.write("<hr>");
    myWindow.document.write("<center><img src='images/cfi.png'></center>");
    myWindow.document.write("<hr>");
    myWindow.document.write("<hr>");
    myWindow.document.write("<p><font color='black'>ISO-Request ID: </font><font color='red'><?php echo $rstd_comp['iso_id'];?></font> || <font color='black'>Completion Date:</font>  <font color='red'><?php echo $rstd_comp['comp_date'];?></font></p>");
    myWindow.document.write("<hr>");
    myWindow.document.write("<p><font color='black'>Initiated By: </font><font color='red'><?php echo $rstd_comp['iso_req_name'];?></font> || <font color='black'>Forwarded By: </font><font color='red'><?php echo $rstd_comp['iso_req_bname'];?></font></p>");
    myWindow.document.write("<hr>");
    myWindow.document.write("<p><font color='black'>Approved By: </font> <font color='red'><?php echo "( "; echo $rstd_comp['fwd_by']; echo" )";?></font> || <font color='black'>Sent By:</font>  <font color='red'><?php echo $rstd_comp['iso_itmgr'];?></font>                              </p>");
    myWindow.document.write("<hr>");
    myWindow.document.write("<p><font color='black'>Completed By: </font> <font color='red'><?php echo "( "; echo $rstd_comp['iso_resp']; echo" )";?></font></p>");
    myWindow.document.write("<hr>");
    myWindow.document.write("<hr>");

    myWindow.document.close();
    myWindow.focus();
    myWindow.print();
    myWindow.close();

  }
</script>
<body>

<input type="button" class="btn" onclick="completed()" value="Print this ISO-Request" />

</body>
</html>