Javascript 如果使用了preventDefault,如何继续下载?
我有一个jQuery模式用户界面,基本上阻止用户下载文件。我使用Javascript 如果使用了preventDefault,如何继续下载?,javascript,jquery,Javascript,Jquery,我有一个jQuery模式用户界面,基本上阻止用户下载文件。我使用preventDefault停止下载管理器的显示。但这会杀死GET 用户单击“同意”后,如何请求继续下载 我已经用谷歌搜索过了,大多数人都在做表单提交。记住文件的URL,然后将其设置为窗口。当用户单击同意时,位置 HTML: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link
preventDefault
停止下载管理器的显示。但这会杀死GET
用户单击“同意”后,如何请求继续下载
我已经用谷歌搜索过了,大多数人都在做表单提交。记住文件的URL,然后将其设置为
窗口。当用户单击同意时,位置
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
</head>
<body>
<a href="http://google.com" id="btn">Button</a>
<div id="dlg">Continue?</div>
</body>
</html>
var dlg$ = $('#dlg').dialog({
title: 'Confirm action',
autoOpen: false,
buttons: {
'Agree': function() {
dlg$.dialog('close');
window.location = dlg$.data('url');
}
}
}),
btn$ = $('#btn').on('click', function(e) {
e.preventDefault();
dlg$.data('url', this.href).dialog('open');
});
window.location='UrlToFile'
?一个代码示例可以帮助我们。或者简单到window.location=$(this.target.href
,其中如果他感到困惑,this
就是
标记。