Author Topic: non-image-containing-link selector - for external link detecting  (Read 2195 times)

mr-fan

  • Guest
hi guys,

here maybe some usefull code for detecting external links automatically without setting rel=external or target=_blank or something else.... :wink:

Code: [Select]
$(document).ready(function() {
$('a:not(.nojqueryanchor):not(:has(img))').filter(function() { return
this.hostname && this.hostname !== location.hostname; }).after('
').attr('target', '_blank');});

for XHTML strict use something like this instead of .attr('target', '_blank') :
Code: [Select]
  .click(function() {
    window.open(this.href);
    return false;

regards martin

Offline crnogorac081

  • Posts: 1899
  • Gender: Male
Re: non-image-containing-link selector - for external link detecting
« Reply #1 on: August 12, 2010, 03:03:23 PM »
Also it could be done that same JQ code adds "open in new window" image next to link..

It looks fancy :)

cheers
« Last Edit: August 17, 2010, 09:18:29 AM by Argos »
no bb in signature

 

postern-length