0
我有一个jQuery模态UI基本上阻止用户下载文件。我使用preventDefault
来停止下载管理器显示。但是这会杀死GET
。如果使用preventDefault,我该如何继续下载?
用户点击Agree
后,如何请求继续下载?
我已经使用了这个,他们大多数都在做表单提交。
我有一个jQuery模态UI基本上阻止用户下载文件。我使用preventDefault
来停止下载管理器显示。但是这会杀死GET
。如果使用preventDefault,我该如何继续下载?
用户点击Agree
后,如何请求继续下载?
我已经使用了这个,他们大多数都在做表单提交。
记住文件的URL,然后将其设置为window.location
,当用户点击Agree
时。
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>
的JavaScript:
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 = $(this).target.href'一样简单,如果他感到困惑,那么'this'就是''标签。 – CppLearner
'了window.location =“UrlToFile''? –
代码示例将帮助我们帮助您。 –