gpt4 book ai didi

javascript - 使用 jquery 将表内容导出到 excel 在 IE 8 中不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 13:28:47 27 4
gpt4 key购买 nike

在这里,我尝试将表格内容导出到 excel。它在 Firefox 中运行良好。但它在 IE 8 中不起作用。有人可以帮我解决这个问题吗?我在这里使用了jquery。如果也可以使用 javascript,我同意。

<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script>
$(document).ready(function() {
$("[id$=excellink]").click(function(e) {
alert("$('div[id$=dvData]').html()");
window.open('data:application/vnd.ms-excel,' + encodeURIComponent( $('div[id$=dvData]').html()));
e.preventDefault();
});
});
</script>
<body>
<br/>
<div id="dvData">
<table>
<tr>
<th>Billing System</th>
<th>Market Code</th>
<th>Payment Amount</th>
</tr>
<tr>
<td>RED</td>
<td>222</td>
<td>$103.00</td>
</tr>
<tr>
<td>BLUE</td>
<td>111</td>
<td>$13.00</td>
</tr>
<tr>
<td>GREEN</td>
<td>555</td>
<td>$143.00</td>
</tr>
</table>
</div>
<br/>
<input type="button" id="excellink" value="Excel" />

</body>
</head>
</html>

最佳答案

尝试添加特定于 IE 8 的波纹管代码

    <!--[if eq IE 8]>
<script>
$(document).ready(function() {
$("[id$=excellink]").click(function(e) {
alert("$('div[id$=dvData]').html()");
window.open('data:application/vnd.xls,' + encodeURIComponent( $('div[id$=dvData]').html()));
e.preventDefault();
});
});
</script>
<![endif]-->

关于javascript - 使用 jquery 将表内容导出到 excel 在 IE 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24408430/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com