我正在使用jquery 打印插件
$(document).ready(function() {
$(".printButton").printPage({
url: "pages/report.html",
attr: "href",
message:"Your document is being generated"
});
});
带有上述脚本的 Jsp 页面
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script>
$(document).ready(function() {
$(".printButton").printPage({
url: "pages/report.html",
attr: "href",
message:"Your document is being generated"
});
});
</script>
</head>
<body>
<h1>Press Yes to Print </h1>
<p><a class="printButton" href='exception.jsp'>Yes</a></p>
</body>
</html>
第一次打开页面,按yes,一次打印,第二次打开页面,按yes,单击打印2页,第三次单击打印3页。
它意味着每次点击时,jquery 打印插件库都会一次又一次地加载。我们该如何控制呢?