![](/img/trans.png)
[英]How to stop function reload(window.reload) on jquery or javascript?
[英]Uncaught TypeError: window.reload is not a function
我正在尝试从 div 中打印图像,代码运行正常,但是当打印对话框弹出时,我希望页面保持不变,而实际上它只显示图片,因为window.reload
不起作用由于某些原因。 javascript 在控制台中告诉我"Uncaught TypeError: window.reload is not a function"
但我不明白为什么。
function printDiv(printableArea) {
var printContents = document.getElementById("printableArea").innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
window.close();
window.reload();
}
点击打印
<input type="button" onclick="printDiv('printableArea')" value="print a div!" />
您收到错误的原因是没有window.reload()
方法。 您可能希望使用location.reload()
来重新加载页面。
不确定是否有这样的功能,试试location.reload()
使用location.reload();
或window.location.reload(true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.