此示例在 jsFiddle 中运行良好,但将表格导出到 Excel 工作表中
我保存在PC中,如下面的代码
<html>
<head>
<title>Table Export</title>
<script src="jquery.js"></script>
<script type="text/javascript">
$("#btnExport").click(function (e) {
window.open('data:application/vnd.ms-excel,' + encodeURIComponent($('#dvData').html()));
e.preventDefault();
});
</script>
</head>
<body>
<br/>
<div id="dvData">
<table>
<tr>
<th>Column One </th>
<th>Column Two</th>
<th>Column Three</th>
</tr>
<tr>
<td>row1 Col1</td>
<td>row1 Col2</td>
<td>row1 Col3</td>
</tr>
<tr>
<td>row2 Col1</td>
<td>row2 Col2</td>
<td>row2 Col3</td>
</tr>
<tr>
<td>row3 Col1</td>
<td>row3 Col2</td>
<td>row3 Col3</td>
</tr>
</table>
</div>
<br/>
<a href="" id="btnExport">edit</a>
</body>
</html>
但这不起作用并导出文件,但其他 jQuery 示例有效,有什么问题?