簡體   English   中英

Javascript window.open在鏈接上無法在PHP中運行

[英]Javascript window.open on link isn't working within PHP

我的網頁頂部有以下腳本,用於根據傳遞的URL參數打開彈出窗口...

<Script Language="JavaScript">
function showDetails(source) {
    window.open(source,"","scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no");
}
</Script>

而且我有以下PHP代碼,該代碼調用該函數來打開窗口並傳遞url ...

$QueryResult = @$this->DBConnect->query($SQLString);

            if ($QueryResult !== FALSE) {
                if ($QueryResult->num_rows > 0) {       
                    while (($Row = $QueryResult->fetch_assoc())
                                    !== NULL) {
                        echo "<br /><a href='javascript:showDetails(http://server/~user/PHP/EventDetails.php?PHPSESSID=".session_id()."&EventID=".$Row['EventID'].")'>".
                                htmlentities($Row['Title'])."</a>";
                    }
                }
                echo "</td>";

                if ((($FirstDOW + $i) % 7) == 0) {
                    echo "</tr>";
                }
            }

當我將鼠標懸停在網頁上的鏈接上時,傳遞給該函數的URL看起來不錯,並且在瀏覽器底部看到了類似的內容,但是,當我單擊該鏈接時,它沒有任何作用...

javascript:showDetails(http://server/~user/PHP/EventDetails.php?PHPSESSID=Hij3234Abdc732hlae&EventID=2)

您通常將字符串放在引號中,例如

echo "<br /><a href='javascript:showDetails(\"http://server/~user/PHP/EventDetails.php?PHPSESSID="
    .session_id()."&EventID=".$Row['EventID']."\")'>".
                            htmlentities($Row['Title'])."</a>";

語法錯誤。

echo "<br /><a href='javascript:showDetails(\"http://server/~user/PHP/EventDetails.php?PHPSESSID=".session_id()."&EventID=".$Row['EventID']."\")'>".htmlentities($Row['Title'])."</a>";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM