JavaScript-前进后退window.history.go(1)-后退window.history(-1)-设置地址栏上url:window.location.href=' 网址'
1、前进:onclick="window.history.go(1)"
2、后退:onclick="window.history.go(-1)"
onclick="window.history.back()"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>006-history对象.html</title>
<!--006--007联合起来看代码 -->
</head>
<body>
<a href="007.html">007页面</a>
<input type="button" value="前进" onclick="window.history.go(1)"/>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>007</title>
</head>
<body>
007page!
<input type="button" value="后退" onclick="window.history.back()"/>
<input type="button" value="后退" onclick="window.history.go(-1)"/>
</body>
</html>
3、设置浏览器地址栏上的url:window.location.href=' 网址'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>008设置浏览器地址栏上的url</title>
<!--
window.location.href="url"
<input type="button" value="百度" onclick="goBaidu()">
-->
</head>
<body>
<script type="text/javascript">
function goJD(){
window.location.href='http://www.jd.com'
}
function goBD(){
window.location.href='http://www.baidu.com'
}
</script>
<input type="button" value="京东" onclick="goJD()" >
<input type="button" value="百度" onclick="goBD()" >
</body>
</html>