新しいウィンドウをpostで開き、URLの後ろのパラメータを隠します.

4133 ワード

       windowOpen:function(url){// post       
            var map = {};   
            if (url.indexOf('?') != -1) {   
                var str = url.substr(url.indexOf('?')+1);   
                strs = str.split('&');   
                for(var i = 0; i < strs.length; i ++) {   
                    map[strs[i].split('=')[0]]=unescape(strs[i].split('=')[1]);   
                }   
                url = url.substr(0,url.indexOf('?'));
            }   
            var winFormName = generUUID();
            var tempForm = document.createElement("form");    
            tempForm.id = winFormName;  
            //          post  
            tempForm.method="post";   
            //  window.open url,     action     
            tempForm.action = url;  
            //     target     window.open     (           )  
            tempForm.target="_blank"; 
            $.each(map, function(key, val) {
                var hideInput = document.createElement("input");    
                hideInput.type ="hidden";    
                hideInput.name = key;  
                hideInput.value = val; 
                // input    form     
                tempForm.appendChild(hideInput); 
                //formHtml += "";
            });
            //  form         body   
            document.body.appendChild(tempForm); 
            //    ,      
            tempForm.submit();
            // body   form    
            document.body.removeChild(tempForm);  
        }