打印/打印预览在谷歌浏览器中不起作用

时间:2014-12-22 13:07:45

标签: javascript google-chrome

当我点击打印按钮时,打印预览仅失败了Google Chrome。其他浏览器工作正常。我找不到这个问题。为什么打印预览失败?

<!doctype HTML>
<html>
<head>

<script type="text/javascript" src="/jquery-2.1.1.min.js"></script>     
<script type="text/javascript">

function PrintImage() {

    var x = window.open('','_blank','location=0');

    x.document.body.style.margin = '0';

    x.document.body.innerHTML = '';
    x.document.write("<!DOCTYPE html>");
    x.document.write("<html style='margin:0px;'><head></head><body onload='printpage()' style='margin:0px;'>");
    x.document.write("<img src='http://10.78.129.248:8080" + $('#imgFront').attr('src') + "' style='margin:0px;border:0px;display:block;height:100%;width:100%;" /* + $('#imgFront').css('height') + "; width:" + $('#imgFront').css('width') + */  + "'/>");
    x.document.write("</body></html>");
    x.document.close();
    x.focus();
    x.print();
    x.close();
}
</script>

</head>
<body>
<img id="imgFront" src="/badgeimagehandler.jpg" align="middle" border="0" style="width: 80mm; height: 50mm" />

<form>
<input type="submit" name="btnPrint" value="Print" onclick="javascript:PrintImage();" language="javascript" id="btnPrint" /> <!-- -->
</form>

</input>
</body>
</html>

0 个答案:

没有答案