Javascript:未定义标头
我已经在JavaScript中尝试了两个重定向,即Javascript:未定义标头,javascript,php,Javascript,Php,我已经在JavaScript中尝试了两个重定向,即窗口.location.href()和标题(),但始终显示一个错误: ReferenceError:未定义标头 我的PHP代码: echo "<script> header('location: index.php');</script>"; echo“头('location:index.php');”; 您不需要使用jquery 试试这个 您不需要使用jquery 试试这个 JavaScript中没有header()函
窗口.location.href()
和标题()
,但始终显示一个错误:
ReferenceError:未定义标头
我的PHP代码:
echo "<script> header('location: index.php');</script>";
echo“头('location:index.php');”;
您不需要使用jquery
试试这个
您不需要使用jquery 试试这个 JavaScript中没有
header()
函数header()
是一个PHP函数。以下是使用JS重定向的一种方法:
echo "<script> window.location.href = 'index.php'; </script>";
JavaScript中没有header()
函数header()
是一个PHP函数。以下是使用JS重定向的一种方法:
echo "<script> window.location.href = 'index.php'; </script>";
您可以通过以下代码轻松实现: 对于PHP中的JavaScript:
echo '<script>window.location.href="YOURURL.COM"</script>';
您可以通过以下代码轻松实现: 对于PHP中的JavaScript:
echo '<script>window.location.href="YOURURL.COM"</script>';
header()
是一个php函数。在发送任何实际输出之前,必须调用header()
,无论是通过普通HTML标记、文件中的空行还是从PHP
<?php
header("Location: index.php"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
参考:
在jstry中,window.location.href=“index.php”
//重定向URLheader()
是一个php函数。在发送任何实际输出之前,必须调用header()
,无论是通过普通HTML标记、文件中的空行还是从PHP
<?php
header("Location: index.php"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
参考:
在jstry中,
window.location.href=“index.php”
//重定向URLheader()
是一个php函数,这就是为什么它在JavaScript中没有定义。只是标题('location:index.php');退出代码>是必需的。但是,不要将其回送。header()
是一个php函数,这就是为什么它在JavaScript中未定义的原因。只是标题('location:index.php');退出代码>是必需的。但是,不要回声。错误地使用代码。非常感谢。我忘记了头()是PHP。如果我没有考虑<代码>退出,<代码>可以吗?不可以,因为如果您在标题()下有代码,它仍然会执行。错误使用代码。非常感谢。我忘记了头()是PHP。如果我没有考虑<代码>退出,<代码>可以吗?不可以,因为如果在header()
下面有代码,它仍然会执行。