12
I have a page that can be opened both by my own domain and externally, both as a "normal" window and as a popup.
In this window, I need to check whether it was opened as a popup or not, and perform some customizations programmatically. So far, was using the following approach (widely recommended):
if (window.opener)
// É um popup
else
// Não é um popup
Yet I have found compatibility problems with the Internet Explorer, which causes the attribute opener
is not completed.
Could someone tell me some alternative to perform this check?
Obs:
- In general, I cannot change the code that opens the window (e.g., to include querystring parameters)
- When I say open as popup, I mean a call to
window.open()
.
Have you considered using the header HTTP Referrer to verify the source of the request on the server and then, for example, redirect or include a script according to the source?
– utluiz
@utluiz Unfortunately, it is not the referrer who defines the way the window is being opened (popup or not)... I included it in the explanation just to make the scenario better understood.
– everton
Right. Were you able to test Erik’s response? It worked?
– utluiz
@utluiz Yes, but anyway it will not be possible to follow with this approach, because this would imply in changing all the places that are opening this popup, and many of them are from other third systems.
– everton
Maybe my answer to use
window.opener
work. =)– Miguel Angelo