摘自: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" 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>

 

相关文章:

  • 2021-05-09
  • 2021-06-04
  • 2022-12-23
  • 2021-12-19
  • 2021-11-29
  • 2021-06-18
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2021-04-03
  • 2021-11-21
  • 2021-06-22
  • 2021-09-03
  • 2021-06-09
  • 2021-10-23
相关资源
相似解决方案