1.使用header()函数跳转 header()函数中Location类型标头通常用来实现页面跳转。看下面php代码:
- <?php
- header("Location: http://www.");
- exit;
- ?>
需要注意的是header()函数前最好不要有输出内容,header()后面的php代码依然将会执行。 2.使用meta标签实现跳转。 注意参数的设置:http-equiv必须为refresh,content="秒数;url=网址"。 如下php代码:
- <?php
- $url = "http://www.";
- ?>
- <html>
- <head>
- <meta http-equiv="refresh" content="3; url=<?php echo $url; ?>">
- </head>
- <body>
- 停留了3秒。。。
- </body>
- </html>
3.通过js脚本实现页面跳转。 建议使用,这种方法可以出现在任何位置,没有限制。
- <script language='javascript' type='text/javascript'>
- window.location.href="http://www.";
- </script>
当然上面的url可以是php变量,还可以用window.open()实现跳转。
|