How to Create Auto Pop-Up Tabs/Windows for External Links

How to Create Auto Pop-Up Tabs/Windows for External Links

Ever get sick of having to repeatedly set target out your various links? Well you should be, the target attribute is deprecated. In this tutorial we'll use jQuery to automatically render all external links to open new tabs/windows.

It's really easy: just assign the function to all a by targeting leading http within each href attribute. That's it! Simple, right?

  1. $(document).ready(function(load){
  2.  
  3. $('a[href^="http"]').live('click',external_link);
  4.  
  5.  
  6. function external_link(e){
  7.  
  8. var $link= $(this);
  9. var $link_execution= "";
  10.  
  11.  
  12. $link_execution= window.open($link.attr('href'),$link.attr('rel'),"toolbar=0,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=900,height=600");
  13.  
  14.  
  15. return false;
  16.  
  17. }
  18.  
  19. });

Tags

Add Comment

Leave a Comment or Reply
Fuel the conversation with your thoughts using the form below. Email is not made public.
× Processing...

Please Wait while your Comment is being Processed.

*
*
*

Comments 0 Total Responses