1 //目的:提供開啟視窗的畫面
2 //參數:strUrl-->欲開啟畫面的網址,strParms-->參數,width-->畫面的寬度,height-->畫面的高度
3 // WinName-->開啟的視窗名稱
4 // xx. YYYY/MM/DD VER AUTHOR COMMENTS
5 // 1. 2016/08/22 1.00 Anne Create
6 function OpenNewWin(strUrl,aryParms,width,height,WinName)
7 {
8 var top=0;
9 var left=0;
10 if (height =='' && width==''){
11 width=screen.availWidth;
12 height=screen.availHeight;
13 }else if (height >screen.availHeight && width>screen.availWidth){
14 width=screen.availWidth;
15 height=screen.availHeight;
16 }else{
17 top=(screen.availHeight-height)/2;
18 left=(screen.availWidth-width)/2;
19 }
20 var newWindow = window.open("",WinName,'width='+width+'px,height='+height+'px,dependent,left='+left+',top='+top+',status=no,toolbar=false,menubar=no,scrollbars=yes,resizable=yes',true);
21 if (!newWindow) return false;
22
23 var html ="";
24 //參數的處理
25 //var aryParm=strParms.split("&");//有多少個參數
26 var i=0;
27 for(i=0;i<aryParms.length;i++)
28 {
29 //var aryParaTemp = aryParm[i].split("=");//每一個參數
30 var aryParaTemp = aryParms[i];
31 html += "<input type='hidden' name='" + aryParaTemp[0] + "' value='" + aryParaTemp[1] + "'/>";//參數字段
32 }
33 html = "<html><head></head><body><form id='formid' method='post' action='"+strUrl+"'>"+html;
34 html += "</form><scr"+"ipt type='text/javascript'>document.getElementById('formid').submit()</scr"+"ipt></body></html>";
35 //html += "</form><script type='text/javascript'>document.getElementById('formid').submit()</script></body></html>";
36 newWindow.document.write(html);//提交post數據
37 }
38
39 //目的:提供開啟視窗的畫面(跨域跳转的话,用OpenNewWin方法,IE浏览器不兼容,故重写一个)
40 //參數:strUrl-->欲開啟畫面的網址,strParms-->參數,width-->畫面的寬度,height-->畫面的高度
41 // WinName-->開啟的視窗名稱
42 function openNewWin_IE(strUrl,strParam,width,height,name)
43 {
44 var tempForm = document.createElement("form");
45 tempForm.id="tempForm1";
46 tempForm.method="post";
47 tempForm.action=strUrl;
48 tempForm.target=name;
49 var hideInput = document.createElement("input");
50 hideInput.type="hidden";
51 hideInput.name= "param"
52 hideInput.value= strParam;
53 tempForm.appendChild(hideInput);
54 tempForm.attachEvent("onsubmit",function(){funWinOpen("",width,height,name);});
55 document.body.appendChild(tempForm);
56 tempForm.fireEvent("onsubmit");
57 tempForm.submit();
58 document.body.removeChild(tempForm);
59 }
60 function openNewWin_IE11(strUrl,strParam,width,height,name)
61 {
62 var tempForm = document.createElement("form");
63 tempForm.id="tempForm1";
64 tempForm.method="post";
65 tempForm.action=strUrl;
66 tempForm.target=name;
67 var hideInput = document.createElement("input");
68 hideInput.type="hidden";
69 hideInput.name= "param"
70 hideInput.value= strParam;
71 tempForm.appendChild(hideInput);
72 tempForm.addEventListener("onsubmit",function(){funWinOpen("",width,height,name);});
73 document.body.appendChild(tempForm);
74 tempForm.submit();
75 document.body.removeChild(tempForm);
76 }
77 function funWinOpen(strUrl,width,height,WinName)
78 {
79 var top=0;
80 var left=0;
81 if (height =='' && width==''){
82 width=screen.availWidth;
83 height=screen.availHeight;
84 }else if (height >screen.availHeight && width>screen.availWidth){
85 width=screen.availWidth;
86 height=screen.availHeight;
87 }else{
88 top=(screen.availHeight-height)/2;
89 left=(screen.availWidth-width)/2;
90 }
91 var newWindow = window.open(strUrl,WinName,'width='+width+'px,height='+height+'px,dependent,left='+left+',top='+top+',status=no,toolbar=false,menubar=no,scrollbars=yes,resizable=yes',true);
92 }