Javascript window.open on link 在 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>";