我在通过 php 动态回显 javascript 时遇到了一些问题。这是我的代码
$url = "http://www.newsite.com";
echo "
<html>
<head>
<title>Redirecting</title>
</head>
<body onload='redirect()'>
Not Logged In
<script type = 'text/javascript'>
function redirect() {
window.location=".$url."
}
</script>
</body>
</html>
";
我的 javascript 控制台告诉我找不到“redirect()”(未捕获的引用错误:未定义重定向)
有什么想法造成这种情况吗?
完全放弃基于客户端的重定向。使用:
header("HTTP/1.0 302 Moved Temporarily");
header("Location: $url");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)