I can not close a pop-up

2

The following code belongs to a pop-up that I am trying to close with javascript but it does not work for me and it does not give me any errors either.

<div id="popup-box-outer">
    <div id="popup-box">
    <h1><img src="<?=$path?>images/lingerie/logo-confirm.png" style="width: 135px; height: 130px; margin-left: 310px;"></h1>
    <p style="color: #fff;">Clinica Doctor Amor contiene material sexualmente explícito que puede ser ofensivo para algunos espectadores. Por favor, lea y acepte los términos y condiciones.</p>
     <p style="color: #fff;">
    Este sitio web provee acceso a material, información y comentarios que pueden ser considerados de carácter exclusivamente adulto y puede ser considerado ofensivo según sus principios sociales, morales y/o religiosos.</p>
 <p style="color: #fff;">
 Absténgase de entrar a este sitio si usted fácilmente puede ofenderse o si los estándares en su comunidad no permiten la visualización de algún material erótico adulto. Si usted no ha adquirido la mayoría de edad (mayor de 18 años) opte por SALIR de esta página inmediatamente. </p>
    <p style="color: #fff;">
        Al entrar a este sitio web y visualizar su contenido, usted está explícitamente afirmando que:
    </p>

<div class="divider-sm"> </div>
  <p>

    <a class="btn" onclick="top.close();" style="margin-left: 200px; font-weight: bold;"><?= texto('estoy de acuerdo') ?></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <a href="#" class="btn" onclick="history.go(-1);" style="font-weight: bold;"><?= texto('no estoy de acuerdo') ?></a>

  <p>


</div>
</div>

What could be the cause of avoiding closing this pop-up using the javascript code that I attached in this question?

    
asked by Francisco Javier Restrepo 20.04.2016 в 22:33
source

2 answers

2

A window can only be closed with Javascript if it has been previously opened with Javascript.

What you ask with top is a reference to the parent window, which can not close itself. Test with window.close(); simply.

Or better yet, change the visibility of div class="divider-sm" : display:block when you want to show it, display:none when you want to hide it. Playing a bit with CSS you will have a popup with the look you want.

    
answered by 01.07.2016 в 13:55
0

simply removes the containers from the text that is inside the anchor, are causing error and does not allow history.go(-1 to be executed):

<?= texto('no estoy de acuerdo') ?>

It would only be:

<a href="#" class="btn" onclick="history.go(-1);" style="font-weight: bold;">no estoy de acuerdo</a>
    
answered by 20.04.2016 в 22:47