有人可以告诉我为什么 Javascript 中的“printArea”是未定义的。
<html>
<head>
<script language="text/javascript">
function printArea(areaName)
{
var printContents = document.getElementById(areaName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
</script>
</head>
<body>
<div id="printThis">
Hello I am a printable area
</div>
<input type="button" onclick="printArea('printThis');" Value="Print">
</body>
</html>
这是 JS Fiddle http://jsfiddle.net/cFeNp/