identify when the page is opened in a popup

0

Is it possible to identify if the page was opened in a pop-up?

I want to do this with javascript or jquery.

I have the test.html page, and if it is opened in a precise pop-up it will appear a link to closing 'close'

Can you do this?

    
asked by anonymous 13.02.2017 / 12:51

1 answer

1

WINDOW.OPENER

When you open a page using techniques such as window.open , the Window.opener variable is fed with the page information that generated the request. If the page has not been opened this way, it returns NULL :

if (window.opener) { // Window.opener recebe os dados da página que gerou a atual
    document.getElementById("fechar").style.display = "block";
} 
#fechar {
  display: none;
}
<a id="fechar">FECHAR</a>

<p>Essa é sua Página.</p>
    
13.02.2017 / 13:03