定义与用法
The target property sets or returns where to open the target URL.
target 属性可用来设置或返回目标URL的打开方式
语法
anchorObject.target=target |
举例
<html> <head> <script type="text/javascript"> function changeLink() { document.getElementById('myLink').innerHTML="ruanchen" document.getElementById('myLink').href="http://www.ruanchen.com"
document.getElementById('myLink').target="_blank" } </script> </head> <body> <a id="myLink" href="http://www.microsoft.com">Microsoft</a>
<br /><br /> <input type="button" onclick="changeLink()" value="Change link"> </body> </html> |
尝试与演示
Change text, URL, and target attribute of a link
改变连接的文字,URL以及目标属性