WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => jQuery => Topic started by: mr-fan on August 12, 2010, 10:14:39 AM

Title: non-image-containing-link selector - for external link detecting
Post by: mr-fan on August 12, 2010, 10:14:39 AM
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
Title: Re: non-image-containing-link selector - for external link detecting
Post by: crnogorac081 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