使用javascript改进链接

摘自《javascript基础教程》

<!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="script002.js"></script>
</head>
<body>
<h2 class="centered">Hey,check out <a href="http://www.pixel.mu/" >my cat's web site</a></h2>
</body>
</html>

 

script002.js

// JavaScript Document
window.onload = initAll;

function initAll() {
document.getElementById("redirect").onclick = initRedirect;
}

function initRedirect() {
alert("We are not response for the content of pages outside our site");
window.location = this;
return false;
}

相关文章:

  • 2021-04-18
  • 2021-12-11
  • 2021-10-15
  • 2021-07-31
  • 2021-09-07
  • 2021-08-15
  • 2021-07-08
  • 2022-12-23
猜你喜欢
  • 2021-11-08
  • 2021-08-24
  • 2022-12-23
  • 2021-04-19
  • 2021-09-19
相关资源
相似解决方案