主要理解target属性的意思:
<html>
<head>
<script type="text/javascript">
function changeLink()
{
document.getElementById('myAnchor').innerHTML="W3School";
document.getElementById('myAnchor').href=" [url]http://www.w3school.com.cn[/url]";
document.getElementById('myAnchor').target="_blank";
}
</script>
</head>
<body>
<a id="myAnchor" href=" Microsoft[url]http://www.microsoft.com[/url]">Microsoft</a>
<input type="button" value="Change link">
</body>
</html>
 
备注:
In this example we change the text and the URL of a hyperlink. We also change the target attribute. The target attribute is by default set to "_self", which means that the link will open in the same window. By setting the target attribute to "_blank", the link will open in a new window.
翻译:
在这个例子中我们改变了文本内容和URL链接,并且我们也改变了链接之后的target属性。
这个属性默认值设为“_self”,意思就是当我们打开一个链接的时候,新的链接会在当前窗口中打开。在此例中我们将其属性更改为"_blank",就是说新的链接将在另外一个窗口中显示。