javascript重定向问题

javascript redirection issue

本文关键字:问题 重定向 javascript      更新时间:2023-09-26

我有两个php文件aff.php和goaff.php

在aff.php中,我执行一些函数,然后将用户重定向到goaff.php

aff.php代码

<?
 here some php functions excuted
?> 
<head>
<script type="text/javascript">
top.location.replace("http://www.example.com/goaff.php?id=text");
</script>
</head>

在goaff.php中,我还执行另一个php代码,然后重定向到网站

goaff.php代码

<?
here an php function excuted using id from aff.php then redirect
$url = "http://www.example.com";
header("Location: $url");
?>

我的问题是aff.php,对于一些用户,它根本不会重定向到goaff.php。我已经通过跟踪aff.php中的id来测试它,并将结果记录在数据库中。我需要知道aff.php的重定向方法是否有问题,我使用了javascript top.location.replaces来防止将页面嵌入框架中,并确保javascript在用户浏览器中启用,但它记录了超过40%的用户没有重定向到goaff.php

我认为您的问题在于重定向:

如果这是问题所在,请使用:

window.location.href = "http://www.example.com/goaff.php?id=text"

而不是

top.location.replace("http://www.example.com/goaff.php?id=text");