我一直在尝试使用 jquery.printElement 插件,但当我单击“打印”链接时没有任何反应,除了控制台中出现此错误消息:
Uncaught TypeError: Cannot read property 'opera' of undefined
我使用的代码如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Print</title>
</head>
<body>
<p id="content">Some text to print</p>
<a href="#" id="printIt">Print</a>
<script src="../common/js/jquery-1.10.1.min.js"></script>
<script src="../common/js/jquery.printElement.js"></script>
<script>
$('#printIt').click(function() {
$('#content').printElement();
});
</script>
</body>
</html>
有人知道为什么会发生这种情况吗?
最佳答案
printElement 插件在内部使用 jQuery.browser,并且 $.browser 已在您使用的 jQuery 版本中被弃用并删除。
您必须使用旧版本的 jQuery,或者可能使用迁移插件才能使 printElement 工作。
关于javascript - jquery.printElement 根本没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18354861/