我正在使用一个名为LeagueLink的PHP变量。当用户没有登录时,我希望变量读取文本(已经有一个联盟…),然后是一个弹出窗口的链接。到目前为止,它显示正确,除了当我点击链接时什么都没有发生。我想我只是因为混合了这么多PHP和JS而出现了语法错误,但我不知道在哪里。如果可以的话,请帮助使弹出窗口链接工作。。。
<?php
// this starts the session
session_start();
$_SESSION['userid'];
$message = "";
if ($_SESSION['userid'] == "") {
$message = "You must create an account or sign in to play!";
$LeagueLink = "Already have a league...<a href='JavaScript:newPopup('"http://www.yourfantasyfootballreality.com/signin.php'");' class='two'>Sign In</a>";
} else {
$message = "Hello, " .$_SESSION['userid'] . " make your picks!";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="js/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="js/jquery-easing-1.3.pack.js"></script>
<script type="text/javascript" src="js/jquery-easing-compatibility.1.2.pack.js"></script>
<script type="text/javascript" src="js/coda-slider.1.1.1.pack.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" href="http://www.indiana.edu/favicon.ico" />
<title>YourFantasyFootballReality</title>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
<body>
<?=$message?>
<?=$LeagueLink?>
<?=$ActionLink?>
</body>
</html>
JavaScript:newPopup
是一个需要定义的函数。
我认为您正在寻找以下内容:您不需要javascript在新窗口中打开页面。只需将链接的target
属性设置为_blank
即可。
$LeagueLink = "Already have a league...<a href='http://www.yourfantasyfootballreality.com/signin.php' target='_blank' class='two'>Sign In</a>";
编辑:如果您希望它弹出,而不是在新选项卡中打开,您可以在它生成后立即调整它的大小。将以下内容添加到您的javascript中。
function newPopup()
{
var url='http://www.yourfantasyfootballreality.com/signin.php';
windowProperties = "toolbar=no,menubar=no,scrollbars=no,statusbar=no,height=500px,width=500px,left=50%,top=50%";
popWin = window.open(url,'newWin',windowProperties);
}
并保持你的PHP和以前一样。