js彈出頁面
js彈出頁面:
- function openAddUser(thisurl){
- var url = thisurl;
- var hWnd = window.open(url,"添加用戶","width=760,height=450,resizable=no,scrollbars=yes") ;
- hWnd.moveTo((screen.availWidth-760)/2,(screen.availHeight-450)/2) ;
- }
以上是父窗口,若要在彈出的窗口(子窗口)調用父窗口的js方法時:
- window.opener.searchOnClick();
searchOnClick()即爲父窗口的方法.
值得注意的是調用父窗口方法時一定要在關閉子窗口前,否則將不會調用父窗口的方法.
- window.opener.searchOnClick();
- closeWindow();
- function closeWindow(){
- window.opener=null;
- window.open("","_self");
- window.close();
- }
- //添加用戶
- function openAddTVStation(thisurl){
- var url = thisurl;
- // screen.availWidth 獲得屏幕寬度
- // screen.availHeight 獲得屏幕高度
- // 居中的算法是:
- // 左右居中: (屏幕寬度-窗口寬度)/2
- // 上下居中: (屏幕高度-窗口高度)/2
- var awidth=860; //窗口寬度,需要設置
- var aheight=450; //窗口高度,需要設置
- var atop=(screen.availHeight - aheight)/2; //窗口頂部位置,一般不需要改
- var aleft=(screen.availWidth - awidth)/2; //窗口放中央,一般不需要改
- var param0="scrollbars=0,status=0,menubar=0,resizable=2,location=0"; //新窗口的參數
- //新窗口的左部位置,頂部位置,寬度,高度
- var params="top=" + atop + ",left=" + aleft + ",width=" + awidth + ",height=" + aheight + "," + param0 ;
- var hWnd = window.open(url,"添加用戶",params) ;
- }
- 點擊按鈕 彈出頁面類似<a target="_blank">彈出</a>:
- window.open("/action.do?method=method&id=${id}","_blank");
- 彈出頁面最大化:
- window.open(url,"","width="+(screen.availWidth-8)+",height="+(screen.availHeight-34)+",top=0,left=0");