簡體   English   中英

刷新父窗口后處理程序彈出窗口

[英]Handler to popup window after refresh parent window

我有一個Java項目,使用Java腳本來管理站點。 我有一個打開幫助對話框彈出窗口的功能。 當我刷新主頁時,彈出窗口沒有關閉,但仍處於打開狀態。 我有一個保護措施,可以在幫助下打開2個窗口,但是它與處理程序(helpWnd)一起使用時,刷新主頁面時會丟失。

對不起我的英語不好;

var helpWnd = null;
// Open help dialog with url from recived helpId
function openHelpDialog(helpId, height, width, title) {
    var url;
    if(helpId == "contact") {
        url = "help/contact.html";
    } else {
        var regularExpression = /[a-zA-Z][a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9]/;
        if(helpWnd!=null) {
            helpWnd.close();
        }
        url = "help/index.html?"+helpId.toLowerCase()+".html";
        if(!regularExpression.test(helpId)) {
            url = "help/index.html";
        }
    }
    helpWnd = window.open(url, title, 'width=1000, height=600, menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=yes, status=no');
}

//this refresh main page
function changeRole(roleName,redirectUrl) {
    dojo.xhrPost({
        content: {
            role: roleName 
        },
        handleAs: "json",
        sync: true,
        url: 'someUrl.npi',
        load: function (response) {
            dojo.cookie(response.cookieHash, response.role, {expires : response.cookieExpiryTime});
            document.location.href = redirectUrl;
        }
    });
}

在許多場合,打開窗戶都被認為是有害的,因為您可能已經發現自己了。

更好的選擇是將模式對話框與javascript一起使用,本質上是同一頁面中的分層對話框。 我不是Dojo專家,但是我很快找到了Google的文檔(http://dojotoolkit.org/reference-guide/1.7/dijit/Dialog.html)

無論如何,如果您仍然想打開窗口,則可以確保確定焦點,從而獲得更好的行為。 在這里看看: http : //www.quirksmode.org/js/popup.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM