JavaScript DHTML/Javascript Objects/history
Содержание
A Browser History Count
<html>
<head>
<title>History Object</title>
<script type="text/javascript">
function showCount() {
var histCount = window.history.length;
if (histCount > 2) {
alert("You have been to " + histCount + " Web pages this session.");
}
}
</script>
</head>
<body>
<form>
<input type="button" name="activity" value="My Activity" onclick="showCount()" />
</form>
</body>
</html>
history back
<html>
<head>
<script language="JavaScript">
function function1(){
history.back(1);
}
</script></head>
<body>
<input id="myButton"
type="button"
onclick="function1();"
value="Go back 1 step in the history list">
</body>
</html>
History.go(-2)
<html>
<head>
<title>History</title>
</head>
<body>
<h1>history object</h1>
<a href="" onclick="history.back();return false">history.back()</a><br />
<a href="" onclick="history.go(-2);return false">history.go(-2)</a><br /><br />
<a href="" onclick="history.forward();return false">history.forward()</a><br />
</script>
</body>
</html>
History length
<html>
<body>
<button onclick="alert(window.history.length);">History Length</button>
</body>
</html>
Hsitory.forward()
<html>
<head>
<title>History</title>
</head>
<body>
<h1>history object</h1>
<a href="" onclick="history.back();return false">history.back()</a><br />
<a href="" onclick="history.go(-2);return false">history.go(-2)</a><br /><br />
<a href="" onclick="history.forward();return false">history.forward()</a><br />
</script>
</body>
</html>
<html>
<head>
<title>history.go() Method</title>
<script type="text/javascript">
function doGoNum(form) {
window.history.go(parseInt(form.histNum.value));
}
function doGoTxt(form) {
window.history.go(form.histWord.value);
}
</script>
</head>
<body>
<form>
<b>Calling the history.go() method:</b>
<hr />
Enter a number:
<input type="text" name="histNum" size="3" value="0" />
<input type="button" value="Go to Offset" onclick="doGoNum(this.form)" />
<p>Enter a word in a title:<input type="text" name="histWord" />
<input type="button" value="Go to Match" onclick="doGoTxt(this.form)" /></p>
</form>
</body>
</html>