identify when the page is opened in a popup

Asked

Viewed 60 times

0

It is 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 opens in a pop-up I need a close link to appear'

You can do it?

1 answer

1


WINDOW.OPENER

When opening a page using techniques such as window.open, the variable Window.opener is fed with the information of the page that generated the request. If the page has not been opened in this way, 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.