gpt4 book ai didi

javascript - JQuery 更改事件下载文件

转载 作者:行者123 更新时间:2023-11-28 10:20:37 25 4
gpt4 key购买 nike

HTML 代码:

<span>Download Report as</span>
<select id="comboFile">
<option value="none">Select</option>
<option value="http://somewhere/123.pdf">PDF</option>
<option value="http://somewhere/123.csv">CSV</option>
</select>

JQuery:

$(document).ready(function () {
$("#comboFile").change(function () {
if ($(this).val() != "none") GetFile($(this).val());
$(this).val("none");
});
});

function GetFile(fileURL){
///Code to be filled
//window.location.href = fileURL;///Does not seem to work for new window
}

我几乎陷入困境..我如何启动文件下载..我需要填写获取文件功能的代码...

最佳答案

$(document).ready(function () {
$("#comboFile").change(function () {
if ($(this).val() != "none") GetFile($(this).val());
$(this).val("none");
});
});

function GetFile(fileURL){
///Code to be filled
//window.open(fileURL);
}

关于javascript - JQuery 更改事件下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5738180/

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