jascript基础教程学习总结(2)
摘自:javascript基础教程
用链接对用户进行重定向:
js001.html
这个HTML页面基于链接对用户进行重定向
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to our site</title>
<script src="script01.js"></script>
</head>
<body>
<h2 class="centered" id="redirect">
welcome to our site ... c"smon in !
</h2>
</body>
</html>
script01.js
// JavaScript Document
window.onload = initAll;
function initAll() {
document.getElementById("redirect").onclick = initRedirect;
}
function initRedirect() {
window.location = "jswelcome.html";
return false;
}
jswelcome.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Our Site</title>
</head>
<body>
<h1>Weclome to our web site,which features lots of cutting-edge JavaScript</h1>
</body>
</html>