js惡補5

主要理解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",就是說新的鏈接將在另外一個窗口中顯示。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章