GreyBox:从函数内部调用弹出窗口

| 在php脚本中,在某些时候我需要显示一个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
    }
?>
上面的代码显示了$ myvar为空但mypage.php永不加载,加载的gif永不停止且Firebug显示指向loader_frame.html的\“ GB null \”错误时的弹出窗口。 我也尝试过:
GB_show(\"Title\", \"mypage.php\");
但同样的问题。 如果我做:
<a href=\"mypage.php\" onclick=\"return GB_showCenter(\'Title\', this.href , 300, 620)\">Click here</a>
页面中的某处,我有没有问题的弹出窗口,因此我知道文件已正确安装。 我究竟做错了什么? 非常感谢!     
已邀请:
我知道这很丑,但是您能尝试一下是否可行:
<?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
    }
?>
好的-另外一个(甚至更丑):
<?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
    }
?>
    

要回复问题请先登录注册