2013-02-15 34 views
1
  • 打開子窗口我有一個父窗口worklist.jsp命名爲
  • 父窗口有一個按鈕。點擊按鈕後,它會調用一個名爲getEventLogUser()的函數。
  • getEventLogUser()函數輪流調用一個名爲popupWindowWithPost()的函數,該函數打開子窗口。這兩個函數是在單獨的js文件(utility.js)..
  • 我的需要是,我必須禁用父窗口時打開子。

worklist.jsp:禁用父窗口使用JavaScript

<div class="claro" id="menuDiv21" onclick="setWidgetproperty(this.id,'x','navMenu21');" onmousedown="setMenuBarProperty('navMenu21');" onmouseup="setDocStyle(this.id)" style="border:1px dotted white; left: auto; position: absolute; top: 620px;"> 
    <div dojotype="dijit.MenuBar" id="navMenu21" style="font-size:11pt;" title="MenuBar"> 
      <div dojotype="dijit.MenuBarItem" id="SearchMenu21" onclick="getEventLogUser();setMenuId(this.id);" style="font-size:11pt;" title="menuBarItem"> 
       <img class="images" id="SearchMenu21" name="search5.png" onclick="setImgProperty(this.id)" src="images/uploads/search.png" style="height:20px; width:20px;"> 
       Search 
      </div> 
</div> 
</div> 

utility.js:

function getEventLogUser(){ 
     var dummyvar = document.getElementById("CWPROCESSEVENTLOG.OBJECT_ID").value; 
     popupWindowWithPost("eventLogUser.jsp",'height=600px,width=960px,top=50px,left=150px,scrollbars=no,sizable=yes,toolbar=no,statusbar=no','processManager',dummyvar); 
} 
function popupWindowWithPost(url, windowoption, name, params) 
{ 
     var form = document.createElement("form"); 
     form.setAttribute("method", "post"); 
     form.setAttribute("action", url); 
     form.setAttribute("target", name); 
     var input = document.createElement('input'); 
     input.type = 'hidden'; 
     input.name = "PARAM"; 
     input.value = params; 
     form.appendChild(input); 
     document.body.appendChild(form); 
     window.open(url, name, windowoption); 
     form.submit(); 
     document.body.removeChild(form); 
} 
+1

當你說'禁用'父窗口..你的意思是用戶不能點擊它的任何東西?即如果他們在子窗口打開時點擊父窗口中的按鈕,該按鈕將不會響應? – abbood 2013-02-15 05:03:06

+0

是的......當孩子打開時,在父窗口中不應該沒有動作... – Rachel 2013-02-15 05:05:37

+0

Rachel請讓我們知道我們的答案是否符合您的需求,或者爲什麼不這樣做,以便我們可以幫助你 – abbood 2013-02-15 05:19:49

回答

0

據我瞭解,你要打開的模態對話框。檢出window.showModalDialog()而不是window.open()。注意,它也有一些不同的參數...

而且,如果你想把它放在form.submit();之前,那麼它將不會被執行,直到模式窗口關閉。

0

查看用於創建模式iframe的fancybox庫。我已經在一些項目中使用了它,它可以做你所要求的;儘管是疊加而不是單獨的窗口。

2

一個簡單的方法來禁用一個窗口(假設您的禁用定義與上面的評論相匹配)是簡單地用一個不可見的div覆蓋窗口,並給它一個令人難以置信的大z-索引,以便如果你有任何其他dom元素Z指數> 1它仍然會被那個看不見的div覆蓋..

嘗試避免像window.showModalDialog()他們是bad news ..如果我是你..我甚至不會創建一個新窗口,除非它是絕對必要的(我不能想到一個真實的單一場景)..我只是在同一個窗口中使用div和css創建一個模態對話框..有大量的教程和庫(即twitter引導)在線。