1

我在下面有这个代码。它工作正常并在 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>
4

1 回答 1

1

Yuppeeeeeeeeeeeeeees.......这是有效的解决方案......适用于 IE 和 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>
于 2013-10-07T13:38:43.583 回答