Open Link List in New Tab

When we add the "Link List" widget or gadget, all  links were open in the same window when clicked which will make your reader leaves your blog/site.

With this simple script, all the links from the "Link List" widget will be open in new tab. Sounds great?!!

Anyway, here's the code:

As usual, from Dashboard > Template > then Edit HTML then,

First,add this line of code above the </head> tag.

 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
Ignore if you have it already.


Then,find </body>  tag and paste the code above it.

<script type='text/javascript'>
 $(function(){
    $("#LinkList1 a").attr("target","_blank");
 });
</script>
Customization:


LinkList1 - Change it depends on the Link List ID.

That's it! Just comment below if it doesn't work.

UPDATE( 2/5/2014) : If you want a specific link in a "link list" to open in new tab. Use this code instead.
<script type='text/javascript'>
 $(document).ready(function() { 
  $("a[href='LINKS HERE']").attr('target', '_blank');} 
 );
</script>

Popular posts from this blog

Set table width to 100% on PDF export in Datatables

Add/Subtract Single Digit Number in Assembly Language