Iklan

How to Make All Links Open in New Tab

How to Make All Links Open in New Tab

Link on a blog a very important point, namely that the reader will still have access to the referral page where he found a new link for the click. In addition, for the blog owner it is also advantageous because visitors do not leave the blog page for their The new tab should be opened.

Here I share 2 How to Make All Links Open in New Tab.


Method 1#


The first way is by adding a script on a widget:

Log in to Blogger > Layout > Create a new widget > Copy and save the code below in it


<script type='text/javascript'>
var arr = document.getElementsByTagName("a"); //get all a links on a page(var i = 0; i < arr.length; i++)
{
if(arr[i].href.indexOf("http://yourhomepage-url.com/") < 0 //not link on this page
&& arr[i].href.indexOf("javascript:") < 0) // link
arr[i].target = "_blank";
}
</script>




Note: Replace the code that is marked with the url of your blog

Save the widget.


Method 2#


The second way is by adding a target command blank on template markup:

Go to Template > Edit HTML > Copy and save the following code before </ head>

<base target='_blank'/>

Save the template and see the results.


So on How to Make All Links Open in New Tab. Good luck.

Next
Prev Post
Previous
Next Post
Buka Komentar