惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
Spread Privacy
Spread Privacy
I
InfoQ
V
V2EX
S
Schneier on Security
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Latest news
Latest news
S
Secure Thoughts
Project Zero
Project Zero
MongoDB | Blog
MongoDB | Blog
I
Intezer
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
量子位
T
Threatpost
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
T
Tor Project blog
A
Arctic Wolf
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
L
LINUX DO - 热门话题

博客园 - 笨笨丁

IIS启用兼容模式设置(win2k3—Win7) C#调用java类、jar包方法(转) 解决VML遭遇IE8和XHTML DOCTYPE时不能运行的问题(转) Nice Validator(Form验证)及Juery zTree控件 ASP.NET程序中 抛出"Thread was being aborted. "异常(转) SQL语句Where中使用别名作为判断条件 50个令人惊奇的jQuery插件(对话框和表单篇)及免费的响应式bootstrap管理员后台界面主题 - Charisma PowerDesigner设计时表显示注释选项 在网页中怎样给已发布的Flash添加链接的方法(zhuan) ASP.NET网站中获取当前虚拟目录的应用程序目录的方法(转) __doPostBack()没有定义解决方法(转) jQuery插件实战之fullcalendar(日历插件) - 使用fullcalendar开发一个功能完整的富客户端会议室预定系统(转) ajaxpro返回值类型总结-DataTable(转) Ibatis.net总是报:【ExecuteStoreCommand SqlParameterCollection 中已包含 SqlParameter】(转) jQuery校验validate详解(转) 一个.NET通用JSON解析/构建类的实现(c#)转 C# JSON字符串序列化与反序列化(转) AjaxPro新发现-错误处理 SVN专题:SVN Client API的.net 接口 SharpSvn介紹 Checkout操作实例,SVN权限(转)
showModalDialog 的重要提示
笨笨丁 · 2013-08-23 · via 博客园 - 笨笨丁

模态对话框,没有opener,不能用window.opener.location.reload();或window.parent.location.reload();
要通过返回值来判断关闭后刷新

function   openWindow(url,   xsize,   ysize)
{
  res   =   showModalDialog(url, " ", "dialogWidth: "+xsize+ ";dialogHeight: "+ysize+ ";status=no;help:no;center:yes ")  
    if   (res== 'ok ')   window.location.reload(1)
}

and   in   the   dialog   use
<td   onclick= "window.returnValue= 'ok ';window.close();   "> Close </td> 

上传文件由于要给一个上传是否成功的提示,因为我们用的是struts2框架,只能通过跳转页面来给提示,由于在模态对话框中,如果再提交页面的话,用户体验就太不好了,因此要选择异步提交,那怎样异步上传文件呢?

从网上找到了一个异步上传文件的插件:ajaxfileupload.js

 $.ajaxFileUpload(
                   {
		                url:'${pageContext.request.contextPath}/${param.url}.action',            //需要链接到服务器地址
		                secureuri:false,
		                fileElementId:'upLoadFile',                        //文件选择框的id属性
		                dataType: 'json',                                     //服务器返回的格式,可以是json
		                success: function (data, status)            //相当于java中try语句块的用法
		                {      
			                if(data.success==true)
			                {
			                    alert('上传成功!');
			                    window.returnValue='ok';//返回值
				  	    window.close(); //关闭窗口
				         }
				  	else if(data.success ==false){		
						  alert('上传失败!');
			                }
		                },
		                error: function(){
					//alert("error");
			         },
			         complete:function(XMLHttpRequest, textStatus){
			               //alert("complete");
			        }
                     }

5. form

<form action="${pageContext.request.contextPath}/uploadFile.action"					
method="post" enctype="multipart/form-data" target="_self">
<input type="file"  name="upLoadFile" id="upLoadFile"  />
<input type="button" value="上传" onclick="ajaxFileUpload()" />
</form>