duanbarong4617
duanbarong4617
2013-10-20 20:31
浏览 32

链接上的Javascript window.open在PHP中不起作用

I have the following script located at the top of my web page to open a popup window based on the URL parameter I pass it...

<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>

And I have the following PHP code that calls the function to open the window and passes the 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>";
                }
            }

When I hover over the link on the web page the URL passed to the function looks fine, and I see something like this at the bottom of the browser, however, when I click the link it does nothing...

javascript:showDetails(http://server/~user/PHP/EventDetails.php?PHPSESSID=Hij3234Abdc732hlae&EventID=2)
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • drt12345678
    drt12345678 2013-10-20 20:34
    已采纳

    Syntax error.

    echo "<br /><a href='javascript:showDetails(\"http://server/~user/PHP/EventDetails.php?PHPSESSID=".session_id()."&EventID=".$Row['EventID']."\")'>".htmlentities($Row['Title'])."</a>";
    
    点赞 评论
  • dongpao1926
    dongpao1926 2013-10-20 20:34

    You normally put strings in quotes, like

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

相关推荐