JS点击下载完毕后取消遮罩层
来源:互联网 发布:大神小的知错了书包网 编辑:程序博客网 时间:2024/05/17 00:07
<html><head><script>var w;var timer;function win(obj) {obj.disabled=true;w = window.open('xjpwb五笔.zip',"","toolbar=no, location=no, directories=no, status=no, menubar=no");timer = window.setInterval('ifWinClosed()',800);}function ifWinClosed(){if(w.closed == true){document.getElementById("click").disabled = false;window.clearInterval(timer);}}</script></head><body><input type="button" name="click" value="click" id="click" onclick="win(this);" /></body></html>
2. 另外的较好方案请看下面链接,大概原理是:在服务器端生成cookie发给client,浏览器设置定时器一直检测是否收到此特定的cookie,收到了说明server下载完毕,响应完成。此时解除遮罩。
http://geekswithblogs.net/GruffCode/archive/2010/10/28/detecting-the-file-download-dialog-in-the-browser.aspx
key code:
$(document).ready(function () { $('#create_pdf_form').submit(function () { blockUIForDownload(); }); }); var fileDownloadCheckTimer; function blockUIForDownload() { var token = new Date().getTime(); //use the current timestamp as the token value $('#download_token_value_id').val(token); $.blockUI(); fileDownloadCheckTimer = window.setInterval(function () { var cookieValue = $.cookie('fileDownloadToken'); if (cookieValue == token) finishDownload(); }, 1000); }function finishDownload() { window.clearInterval(fileDownloadCheckTimer); $.removeCookie('fileDownloadToken'); //clears this cookie value $.unblockUI();}
var response = HttpContext.Current.Response;response.Clear();response.AppendCookie(new HttpCookie("fileDownloadToken", downloadTokenValue); //downloadTokenValue will have been provided in the form submit via the hidden input fieldresponse.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", desiredFileName)); //desiredFileName will be whatever the resutling file name should be when downloaded//Code to generate file and write file contents to responseresponse.Flush();
1 0
- JS点击下载完毕后取消遮罩层
- radio再次点击后取消
- 文本框输入完毕后,点击Enter触发按钮Click事件
- UISearchBar 点击取消后跳动的问题
- JS实现点击下载
- JS实现点击下载
- 【前端JS】radio 可单选可点击取消选中
- js简单的实现点击选中点击取消的效果
- 在HTML页面加载完毕后运行某个js.
- HTML页面加载完毕后运行某个js
- JS实用脚本--页面加载完毕后执行函数
- js单选框选中后如何取消选中
- js 点击后打开链接
- android Dialog的确定按钮点击后不取消对话框
- android Dialog的确定按钮点击后不取消对话框
- tableview中加一个tableview,点击后取消tableview
- UIButton取消点击后的highlight效果(有背景图片)
- Cell点击后返回上页 取消选中状态
- http://yui.github.io/yui2/docs/yui_2.9.0_full/reset/index.html#code
- 连接vpn后不能上网的解决办法
- Servlet 工作原理解析
- glViewport()函数和glOrtho()函数的理解
- jsp编码问题
- JS点击下载完毕后取消遮罩层
- PAT 1046. Shortest Distance (20)【卡的是超时】
- linux下C程序插入执行shell脚本
- 相由心生
- 驱动层-0 写在前面的话:驱动层的面向对象
- IOS 解决键盘挡住输入框的问题
- html表单对输入数据的几种限制的绕过
- SmartUpload用法
- 在开发板的串口终端出现 > 时的退出方法