Posted By

touffies on 11/12/10


Tagged

jquery externalLinks


Versions (?)

Function ExternalLinks with array of domains


 / Published in: jQuery
 

  1. /* ------------------------------------------------------------------
  2.   External Link ---------------------------------------------------- */
  3. $.fn.externalLinks = function(arrDomains) {
  4. return this.each( function() {
  5. $("a", this)
  6. .filter(function(){
  7. for ( var i=0; i < arrDomains.length; i++ ){
  8. if(this.href.indexOf(arrDomains[i])>-1 ) { return false; }else{ return true; }
  9. }
  10. })
  11. .attr({ target:"_blank", rel:"external" });
  12. });
  13. };

Report this snippet  

You need to login to post a comment.