HTML,JS,PHP,Thinkphp实现页面重定向小结
html 页面跳转方式
<!--Add by mike1314-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Author" CONTENT="mike1314">
<meta http-equiv="refresh" content="0; URL=http://www.cnblogs.com/mike1314/">
<script>
</script>
</HEAD>
<BODY>
This is Test Page
</BODY>
</HTML>
**************************************************************
JS 页面跳转方式
1. 使用window.location = "newurl"
<!--Add by mike1314-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Author" CONTENT="mike1314">
</HEAD>
<BODY>
This is Test Page.
<script>
window.location="http://www.cnblogs.com/mike1314/";
</script>
</BODY>
</HTML>
2. 使用 window.navigate
<script>
window.navigate("http://www.cnblogs.com/mike1314/");
</script>
3. window.loction.replace方式实现页面跳转
<script language="JavaScript">
window.location.replace("target.aspx");
</script>
**************************************************************
PHP 页面跳转方式
PHP页面跳转一、header()函数
< ?php
//重定向浏览器
header("Location: <a href="http://www.php.cn" target="_blank">http://www.php.cn</a>");
//确保重定向后,后续代码不会被执行
exit;
?>
PHP页面跳转二、Meta标签
<?php
$url = "http://blog.csdn.net/abandonship";
?>
<html>
<head>
<meta http-equiv="refresh" content="1;url=<?php echo $url; ?>">
</head>
<body>
It's transit station.
</body>
</html>
PHP页面跳转三、JavaScript
<?php
$url = "http://blog.csdn.net/abandonship";
echo "<script type='text/javascript'>";
echo "window.location.href='$url'";
echo "</script>";
?>
**************************************************************
Thinkphp 页面跳转方式
页面跳转
// 操作完成3秒后跳转到 /Article/index
$this->success('操作完成','/Article/index',3);
// 操作失败5秒后跳转到 /Article/error
$this->error('操作失败','/Article/error',5);
页面重定向
$this->redirect('New/category', array('cate_id' => 2), 5, '页面跳转中...');

浙公网安备 33010602011771号