<!DOCTYPE html>
<html>
<head>
<title>Form action</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
.tall {
height: 5000px
}
</style>
<script type="text/javascript">
function submit_pressed(one_two_or_three) {
document.nameOfTheForm.action = "#target_" + one_two_or_three;
return true;
}
</script>
</head>
<body onload="init();">
<h1 id="choose">Choose</h1>
<form name="nameOfTheForm">
<input type="submit" value="Target One" onClick="return submit_pressed('one' );"><br>
<input type="submit" value="Target Two" onClick="return submit_pressed('two' );"><br>
<input type="submit" value="Target Three" onClick="return submit_pressed('three');"><br>
</form>
<div class="tall"></div>
<h1 id="target_one" >Target one </h1><a href='#choose'>Choose again</a><div class="tall"></div>
<h1 id="target_two" >Target two </h1><a href='#choose'>Choose again</a><div class="tall"></div>
<h1 id="target_three">Target three</h1><a href="#choose">Choose again</a><div class="tall"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<title>history.length</title>
<script type="text/JavaScript">
var out;
function main() {
out = document.getElementById('out');
print('History length: ' + history.length);
}
function print(txt) {
out.innerHTML += txt + "<br>";
}
</script>
</head>
<body onload='main()'>
<a href='length_2.html'>go to length_2.html</a>
<div id='out'>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<title>history.length</title>
<script type="text/JavaScript">
var out;
function main() {
out = document.getElementById('out');
print('History length: ' + history.length);
}
function print(txt) {
out.innerHTML += txt + "<br>";
}
</script>
</head>
<body onload='main()'>
<a href='length_1.html'>go to length_1.html</a>
<div id='out'>
</div>
</body>
</html>
window.location.href | The URL of the content that is displaed in the window |
window.location.hostname | The domain of href |
window.location.pathname | The path component of href. Determine HTML document name in JavaScript with window.location.pathname.split('/').pop());. |
window.location.protocol | The protocol that was used to transmit the content to the browser, for example http or https. |
window.location.assign(newUrl) | load newUrl as document into window. |
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<title>window.toString</title>
</head>
<script type="text/javascript">
function main() {
var out = document.getElementById('out');
out.innerHTML = window.toString(); // [object Window]
}
</script>
<body onload='main()'>
<div id='out'>
</div>
</body>
</html>