前端工做有不少地方须要页面跳转,有不少种实现方法,这里作一下概括。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='连接'">
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>