I'm maintaining a large application. In some areas, I have to check if the current window is a popup (opened using window.open()) or a new window (a new tab or window opened using target="_blank").
Here is an example of my problem:
function CancelOutOfPage(cancelPath) {
if (cancelPath != null && cancelPath != "" && window.opener == null) {
location.href = cancelPath;
} else if (referrerUrl != "" && window.opener == null) {
// Just go back
location.href = referrerUrl;
} else {
// It is a popup, close it.
// MY PROBLEM IS HERE. IF THE WINDOW IS NOT A POPUP, BUT A AN OPENED PAGE
// THE WHOLE WINDOW WILL CLOSE
window.close();
}
}
window
opened from you application? – guest271314