当jQuery函数尝试在Firefox中打开新页面时,消息“firefox阻止该站点打开弹出窗口呈现窗口“。据我所知,基于Is window,open() impossible in firefox和Links to local page do not work这是一个本地问题,只发生,因为我试图从“本地主机”访问我的服务器中的文件。但是,当这个网站真的有效时,其他人就不会因为没有访问他们自己的服务器而出现同样的问题。这种解释是否有意义?或者我错了,我必须处理这个问题?顺便说一下,在本地解决这个问题很容易,因为我只是改变了Firefox的偏好。我的担心与访问我网站的其他人有关。Window.open(“about:blank”)=> firefox阻止该站点打开弹出窗口
供参考,这是我的代码:
<?php
$theUsernameDaniel = "danielcajueiro";
$theUsernameMarcelo = "marcelopapini";
?>
<html>
<head>
<meta charset="utf-8" />
<title>ControllingHiperlinks</title>
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$("a.peoplePage").click(function(event) {
event.preventDefault();
var theUsername = $(this).data("username");
// alert(theUsername);
// event.preventDefault();
$.post('callmpeoplepage.php', {theUsername: theUsername}, function(data) {
var thePeoplePage = window.open("about:blank");
thePeoplePage.document.write(data);
});
});
});
</script>
</head>
<body>
<a class="peoplePage" data-username="<?php echo $theUsernameDaniel ?>" href=""> Daniel Cajueiro</a>
<a class="peoplePage" data-username="<?php echo $theUsernameMarcelo ?>" href="">Marcelo Cajueiro</a>
</body>
</html>
callmpeoplepage.php是
<?php
$theUsername = $_POST['theUsername'];
echo $theUsername;
?>
触发window.open的操作是什么? –
@ Collin-Grady请参阅我的更新。 – DanielTheRocketMan