[英]need to redirect url without using the function header
我需要將我的頁面重定向到另一個,但我不能使用header
功能,有沒有其他方法可以做到這一點?
我需要做的是這樣的事情:
if (test){
---do something---
redirect
} else {
return false
}
謝謝
if (test){
---do something---
die("<script>location.href = 'http://www.google.com'</script>");
} else {
return false;
}
元重定向
if (test){
//do something
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=yourpage.php">';//This causes the browser to open the new page after 0 seconds, i.e immediately.
} else {
return false;
}
if (test){
echo "<script type='text/javascript'>
window.onload = function () { top.location.href = '" . $url . "/page.php#contact'; };
</script>";
} else {
return false
}
if (test){
---do something---
$URL="http://yourwebsite.com/";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $URL . '">';
echo "<script type='text/javascript'>document.location.href='{$URL}';</script>";
} else {
return false;
}
如果您想知道為什么我使用Meta標簽和JavaScript重定向 ,那么答案非常簡單。
如果瀏覽器中的JavaScript已禁用,則元標記將重定向頁面。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.