//下面这段代码 <a……>中的 onclick 不会被执行
//我想实现的功能是,让执行链接的同时调用show()函数。应该怎样写?
<html>
<head>
<script type="text/javaScript">
function show()
{
document.write("A function has been called when clicking the link");
}
</script>
</head><body><a href="http://www.sina.com.cn" onclick="show()"> http://www.sina.com.cn </a></body>
</html>
//我想实现的功能是,让执行链接的同时调用show()函数。应该怎样写?
<html>
<head>
<script type="text/javaScript">
function show()
{
document.write("A function has been called when clicking the link");
}
</script>
</head><body><a href="http://www.sina.com.cn" onclick="show()"> http://www.sina.com.cn </a></body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function show() {
alert("test");
location.href="http://www.sina.com.cn";
}</script>
</head>
<body>
<a href="#" onclick="show()"> http://www.sina.com.cn </a>
</body>
</html>
<html>
<head>
<script type="text/javaScript">
function show()
{
document.write("A function has been called when clicking the link");
}
</script>
</head><body><a href="http://www.sina.com.cn" onclick="show();" target="_blank"> http://www.sina.com.cn </a></body>
</html>
开在新窗口,这样才能看到在本document里write。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function show(strurl) {
document.write("A function has been called when clicking the link");
setTimeout(location.href=strurl,100);
}</script>
</head>
<body>
<a href="http://www.sina.com.cn" onClick="show(this.href)"> http://www.sina.com.cn </a>
</body>
</html>