Web实战

JS实现点击链接在新的页面中打开:

黏贴如下代码到<body></body>中
<pre>

<a href=”signup.html”>asdafsdaf</a>
<script type=”text/javascript”>
function externallinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName(“a”);
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute(“href”))
anchor.target = “_blank”;
}
}
window.onload = externallinks;
</script>

</pre>


Sent from Mailbox

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s