Ideas, in the page after loading, will rel contain external a label, through JS plus target= "_blank". The jquery method is provided below, with the following code
| The code is as follows |
Copy Code |
<script type= "Text/javascript" > <!--//--><! [cdata[//><!-- $ (document). Ready (function () { Find all external links and let them open in a new window. $ ("A.external-link"). each (function () { $ (this). Click (function () { window.open ($ (this). attr ("href")); return false; }); }); });
--><!]] > </script> |
Html
| The code is as follows |
Copy Code |
<p> point I open the link in the new window <a href= "http://www.111cn.net" class= "External-link" > Web page Making Tutorials </a> </p> |
JS Native method is as follows:
| code is as follows |
copy code |
| <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; if (Anchor.getattribute ("href") && anchor.getattribute ("rel") = = "external") anchor.target = "_blank"; } } window.onload = externallinks; </script> |
If you don't use JS or jquery to open a new window we can go directly as follows
At the end of page head, add
| The code is as follows |
Copy Code |
| <base target= "_blank"/> |