Domanda

In uno script php, a un certo punto ho bisogno di mostrare un popup GreyBox:

<?php
    if ($myvar==''){
?>
    <script>
    // I need to show mypage.php in a GreyBox popup when in here
   GB_showCenter('Title', 'mypage.php' , 300, 620);

    </script>
<?php
    }
?>

Il codice sopra mostra la comparsa quando $ myvar è vuoto ma mypage.php mai carichi, il GIF carico non smette di girare e spettacoli Firebug un "GB nullo" errore di puntamento per loader_frame.html.

Ho anche provato:

GB_show("Title", "mypage.php");

, ma lo stesso problema.

Se faccio:

<a href="mypage.php" onclick="return GB_showCenter('Title', this.href , 300, 620)">Click here</a>

da qualche parte nella pagina ho il pop-up senza problemi in modo da so che i file siano installati correttamente.

Che cosa sto facendo di sbagliato?

Grazie mille!

È stato utile?

Soluzione

So che questo è brutto, ma si può provare se funziona:

<?php
    if ($myvar==''){
?>
    <script>

        pathArr = window.location.pathname.split('/');
        path = window.location.protocol + "//" + window.location.host+"/";
        for (i=1;i<pathArr.length-1;i++) path += pathArr[i]+"/";

        GB_showCenter('Title', path+'mypage.php' , 300, 620);

    </script>
<?php
    }
?>

OK - un altro (ancora più brutto):

<?php
    if ($myvar==''){
?>
    <a href="mypage.php" onclick="return GB_showCenter('Title', this.href , 300, 620)" style="display: none;" id="myGreyBoxLink">Open GrayBox Window</a>
    <script>
        document.getElementById('myGreyBoxLink').onclick();
    </script>
<?php
    }
?>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top