Today, I was told by A friend that I didn't add A window in the title of "A". How can I open all the pages on the page on the new page? I found several practical methods, my personal favorite is the last method.
The first method is implemented using jquery. The principle is to first find the external link in the site and add the target = _ blank attribute to the link. The Code is as follows:
Jquery opens in a new window
The Code is as follows: |
Copy code |
$ ("A [href * = 'HTTP: // ']: not ([href * ='" + location. hostname + "']), [href * = 'https: //']: not ([href * = '" + location. hostname + "'])") . AddClass ("external ") . Attr ("target", "_ blank "); |
Js opens in a new window
The Code is as follows: |
Copy code |
Var aTag = document. getElementsByTagName ('A '); For (I in aTag ){ Atagpoliciunc.tar get = '_ blank '; } |
Html Method
Add
The Code is as follows: |
Copy code |
<Base target = '_ blank'/> |
You can open all pages in a new window.