1. Open the link on the entire webpage in a new window: add the link to the head
<Base target = "_ blank">
2. Open all links in a DIV in a new window:
Add in body
Copy codeThe Code is as follows:
<Script language = "JavaScript">
<! -
Var anchors = document. getElementById ("DIV name"). getElementsByTagName ("");
For (var I = 0; I <anchors. length; I ++)
{Var anchor = anchors? I ==anchor.tar get = "_ blank ";}
//->
</SCRIPT>
Added whether or not to open the current window
Copy codeThe Code is as follows:
// Control the hyperlink to open in a new window
Var tar = "";
Tar = "_ blank ";
Var urls = document. getElementsByTagName ("");
For (var I = 0; I
{
If(urls+ I }.tar get! = "_ Self "){
Urls[ipolic.tar get = tar;
}
}
3. Open the specified link in a new window:
Open in the original window: <a href = "http://www.baidu.com"> Baidu </a>
Open in the new window: <a tager = "_ blank" href = "http://www.baidu.com"> Baidu </a>