2011-04-27 24 views
2

在PHP腳本中彈出,在某一點上我需要出示了GreyBox彈出: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是空的,但是我的空間。 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> 

的地方,所以我知道該文件被正確安裝。

我在做什麼錯?

非常感謝!

+0

與完整的URL'GB_showCenter( '標題' 嘗試,'http://domain.com/mypage.php',300,620); ' – 2011-04-27 08:07:50

+0

不,不工作:(謝謝 – user712027 2011-04-27 08:14:03

+0

對不起,只是爲了確保......你有沒有在你的腦海中包含GB_showCenter功能? – Karthik 2011-04-27 08:32:35

回答

1

我知道這是醜陋的,但你可以嘗試,如果它的工作原理:

<?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 - 另一個(甚至是醜陋):

<?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 
    } 
?> 
+0

同樣的錯誤,不workin :(謝謝 – user712027 2011-04-27 16:02:06

+0

嘗試新的解決方案 - 我已經更新了我的答案 – 2011-04-28 11:46:42

+0

感謝亞歷山大,但它不是關於使用鏈接。事實上,鏈接結構工作正常,當它在同一頁面中嘗試。問題來了,當試圖從一個if語句觸發窗口。再次感謝 – user712027 2011-04-29 07:43:25