Follow Me

How to Make All Open Links in the New Tab

How to Make All Open Links in the New Tab
How to Make All Open Links in the New Tab - Links to a blog are very important, so that readers still have access to the referral page where they find new links to click on. In addition, for blog owners this is also beneficial because visitors do not immediately leave the blog page because of a new tab that must be opened.

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

Method 1

The first way is to add a script to the 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 links for the page(var i = 0; i < arr.length; i++)
{
if(arr[i].href.indexOf("http://stressthinking.blogspot.com/") < 0 //not the link on this page
&& arr[i].href.indexOf("javascript:") < 0) // link
arr[i].target = "_blank";
}
</script>

Note: Change the code marked with your blog url
Save the widget.

Method 2

The second way is to add the target blank command to the template markup:

Open Template> Click Edit HTML> Copy and save the code below before the code </head>

<base target='_blank' />

Save the template and see the results.

It's all about How to Make All Open Links in the New Tab, good luck.
Next Post Previous Post
No Comment
Add Comment
comment url