• showModalDialog 的重要提示


    模态对话框,没有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>
  • 相关阅读:
    记下mongoose(转载)
    vue vue-cli中引入全局less变量的方式
    单标签不支持 伪元素
    删除tppabs,href="javascript:if(confirm)...",、/*tpa=http://...
    系统字体放大导致rem布局错乱,解决方案,已通过测试
    IE条件注释
    hbase部署经验与坑总结
    ubuntu安装mysql 5.7
    静态代理和动态代理
    单例模式
  • 原文地址:https://www.cnblogs.com/dwfbenben/p/3277927.html
Copyright © 2020-2023  润新知