2

I have a standard Lead page that opens a popup window when a list button is clicked. When the popup is closed, I need the parent window to be refreshed.

My js code:

if(...){...
}    
else{
    window.mypopup = window.open('/apex/HN_SelectProducts?Id={!Lead.Id}&selectedIds='+selIds,'W1', 'toolbar=No, scrollbars=no,resizable=no,titlebar=no,status=no,width=500,height=200,left=220,top=200');
    mypopup.focus();
}

window.onfocus = function() {
    if(!window.mypopup.closed) {
        window.mypopup.close();
        window.location.href = window.location.href;
    }
};

This works in Firefox, but for some reason it doesn't work in Chrome or Safari. Has anyone run into issues of window.close between browsers? How can I handle this situation? Thank you in advance for any suggestions

2 Answers 2

1

I eventually solved my own question. By putting all of the close and refresh logic into my popup page, I was able to get it working.

The basic function that I used was this:

function ClosePopup(){
    var winMain = window.opener;
    if(null == winMain){
       winMain=window.parent.opener;
    }
    winMain.location.href = winMain.location.href; 
    window.top.close();
}
0

I would try to implement a refresg logic in the child (popup) window and refresh the parent directly from the popup. And then close the popup itself:

// Reloadsing the parent window
window.opener.location.reload();

// Closing this popup window
self.close();
1
  • thanks mast0r, I appreciate the feedback. self.close() and window.close() don't work in child windows for some reason, I ended up using window.top.close()
    – rwegner7
    Commented Mar 12, 2015 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .