admin管理员组

文章数量:1794759

HTML页面跳转的方法

HTML页面跳转的方法

1、HTML中使用meta中跳转,通过meta可以设置跳转时间和页面

[html]  view plain  copy
  • <head>  
  • <!--只是刷新不跳转到其他页面 -->  
  • <meta http-equiv="refresh" content="5">  
  • <!--定时转到其他页面 -->  
  • <meta http-equiv="refresh" content="5;url=index.html">   
  • </head>  
  • 2、a标签直接跳转

    [html]  view plain  copy
  • <a href="baidu">百度一下</a>  
  • 3、通过javascript中实现跳转

    [javascript]  view plain  copy
  • // 直接跳转  
  • window.location.href='index.html';  
  • // 定时跳转  
  • setTimeout("javascript:location.href='index.html'", 5000);  
  • 其实两种方式是类似的,只是有的在javascript中写的跳转,另一种直接从html中写跳转 [html]  view plain  copy
  • <button id="load" onclick="window.location.reload('/html/index.html')">跳转</button>    
  • 4、html跳转上一页的方式

    window.history.go(-1);或者window.history.back(-1);

    在html中写

    [html]  view plain  copy
  • <a href=”#” onClick=”JavaScript :history.back(1);”>返回上一页</a>  
  • <a href=”#” onClick=”javascript :history.Go(-1);”>返回上一页</a>  
  • 在javascript中写跳转上一页

    [html]  view plain  copy
  • <div id="btn">按钮</div>  
  • [javascript]  view plain  copy
  • <script type="text/javascript">  
  •     var wrong = document.getElementById('btn');  
  •     wrong.onclick = function() {   
  •     window.history.go(-1);//返回上一页  
  •     window.history.back(-1);//返回上一页  
  •    }  
  • </script>  
  • 本文标签: 跳转页面方法html