IT猫扑网文章教程

分类分类

php页面跳转方法总结

2015-06-28 00:00作者:网管联盟

1.使用header()函数跳转

header()函数中Location类型标头通常用来实现页面跳转。看下面php代码:

  1. <?php
  2. header(&Location: http://www.itmop.com&);
  3. exit;
  4. ?>

需要注意的是header()函数前最好不要有输出内容,header()后面的php代码依然将会执行。

2.使用meta标签实现跳转。

注意参数的设置:http-equiv必须为refresh,content=&秒数;url=网址&。

如下php代码:

  1. <?php
  2. $url = &http://www.itmop.com&;
  3. ?>
  4. <html>
  5. <head>
  6. <meta http-equiv=&refresh& content=&3; url=<?php echo $url; ?>&>
  7. </head>
  8. <body>
  9. 停留了3秒。。。
  10. </body>
  11. </html>

3.通过js脚本实现页面跳转。

建议使用,这种方法可以出现在任何位置,没有限制。

  1. <script language='javascript' type='text/javascript'>
  2. window.location.href=&http://www.itmop.com&;
  3. </script>

当然上面的url可以是php变量,还可以用window.open()实现跳转。

展开全部

相关文章

说两句网友评论
    我要跟贴
    取消