【发布时间】:2014-03-14 13:45:40
【问题描述】:
当 JQuery 函数尝试在 firefox 中打开新页面时,会显示消息“firefox 阻止此站点打开弹出窗口”。据我了解,基于Is window,open() impossible in firefox 和Links to local page do not work 这是一个本地问题,仅在我试图从“本地主机”访问服务器中的文件时才会发生。但是,当这个站点真正运行时,其他人不会因为没有访问自己的服务器而遇到同样的问题。这种解释有意义吗?或者我错了,我必须处理这个问题?顺便说一句,这个问题很容易在本地解决,因为我只更改了 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 请查看我的更新。