页面跳转三种方式

来源:互联网 发布:淘宝店铺如何经营 编辑:程序博客网 时间:2024/06/03 17:41

项目中经常需要进行跳转操作,然后不同的业务场景有不同的需求,下面我列出自己项目中用到的三种场景:

1、通过html标签进行跳转(最简单的方式)

[html] view plain copy
  1. <a  href="http://blog.csdn.net/cl05300629">伫望碧落的博客</a>  

2、通过按钮实现页面跳转

[html] view plain copy
  1. <input  type="button" value="跳转到伫望碧落的博客"  onclick="window.location.href="http://blog.csdn.net/cl05300629}">  

3、通过js实现页面跳转

(1)、在body中添加一个按钮或者其他的html标签,用来调用js方法:

[html] view plain copy
  1. <input type="button" value="跳转到伫望碧落的博客"  onclick="direct()">  

(2)、创建一个js方法:

[html] view plain copy
  1. <script type="text/javascript">  
  2.     function direct(){  
  3.         window.location.href="http://blog.csdn.net/cl05300629";  
  4.     }  
  5. </script>  

第一种方式用于没有要求的直接跳转,第二种用来在需要进行按钮操作跳转的页面,第三种可以对跳转附加跳转条件。
原创粉丝点击