你能看看this demo吗?让我知道为什么在使用 jQuery printElement 插件打印 .table
时出现以下错误?
错误
Uncaught TypeError: Cannot read property 'opera' of undefined
代码:
$(function () {
$('button[type="submit"]').click(function () {
$(this).closest('.panel').find('table').printElement();
});
});
谢谢
最佳答案
问题出在您的 jQuery 版本(2.x edge)上。
打印脚本使用:
if ($.browser.opera || (/chrome/.test(navigator.userAgent.toLowerCase())))
mainOptions["printMode"] = 'popup';
因此您将 jQuery 版本更改为旧版本,它仍然使用 $.browser
支持。
后来不鼓励这样做,因为在针对用户代理字符串进行有条件编程时,x 浏览器和 x 设备支持不能很好地工作。
整个想法的改变始于 jQuery 1.8 版左右。现在,无论您使用哪种浏览器/设备,都建议使用支持检测。
关于javascript - 使用 jQuery printElement 插件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28917528/