javascript:window下的history对象

history对象

history对象包含用户(在浏览器中)访问的URL。可以通过window.history访问。
1.history属性
length:返回浏览器中历史列表中的URL的数量。
2.history方法
(1)back()方法:加载history列表中的前一个URL.
(2)forward():加载history列表中的后一个URL.
(3)go(n):加载history列表中的某个具体页面。n>0向后跳转,n<0向前跳转。go(1)==forward(),go(-1)==back().

以下是实例,historya.html

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>history对象</title>
	</head>
	<body>
		<a href="javascript:location.href='historyb.html'">查看history实例</a>
	</body>
</html>

以下是实例,history.html<!DOCTYPE html>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>history对象</title>
		<script type="text/javascript">
			for(var Property in window.history)
			window.document.write(Property+":"+window.history[Property]+"<br>");
		</script>
	</head>
	<body>
		<a href="navigator.html">navigator</a>
		<input type="button" value="后退" οnclick="javascript:window.history.back();">
		<input type="button" value="前进" οnclick="javascript:window.history.forward();">
		
	</body>
</html>



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章