0
我有一个简单的HTML代码来打印页面。下面是代码:javascript print()方法不能按预期工作
<!DOCTYPE html>
<html>
<head>
<script>
function printPage()
{
var w = window.open("http://www.sigmaaldrich.com/catalog/CofADocRequest.do?symbol=209104&LotNo=MKBP0842V&brandTest=SIGMA","_self");
window.focus();
window.print();
}
</script>
</head>
<body >
<input type="button" onclick="printPage()" value="print a div!" />
</body>
</html>
代码的作用是,它显示一个按钮,点击该按钮后,它会调用一个函数。该函数使用open()通过使用“_self”参数在同一页面中打开一个新的URL。
正如我们可以在代码中看到的那样,print()函数在调用open方法之后被调用。但在我的浏览器IE11中,打印弹出窗口显示为加载页面。 由于这个原因,我不打印正确的页面。
任何人都可以帮助我做到这一点。
结帐这个问题[打印iframe中] [1] [1]:HTTP:/ /stackoverflow.com/questions/27088967/javascript-print-method-is-not-working-as-expected – 2014-11-23 12:46:46