页面跳转的概括

前端工做有不少地方须要页面跳转,有不少种实现方法,这里作一下概括。html

HTML标签

通常形式上能够用<a></a><button></button><input/>前端

<a href="连接">GO</a>
<button onclick="window.location.href='连接'">GO</button>
<input type="button" value="GO" onclick="location.href='连接'">

JS跳转页面代码

本页跳转

window.location.href = '连接';
window.location = '连接';
location.href = '连接';
location = '连接';
top.location = '连接';

新页跳转

window.open('连接');
open('连接');

或者在HTML标签中添加target="_blank":code

<a href="连接" target="_blank">GO</a>

历史跳转

<a href="history.go(-1)">返回上一步</a>
<a href="window.history.back()">返回上一步</a>
相关文章
相关标签/搜索