rizkit1 / jwysiwyg

Automatically exported from code.google.com/p/jwysiwyg
GNU General Public License v2.0
0 stars 0 forks source link

href target #75

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi how to I make all links target new window?

Original issue reported on code.google.com by thuy...@gmail.com on 27 Jan 2009 at 10:18

GoogleCodeExporter commented 8 years ago
Here's how I added the target attribute to this. I have no idea if this is the 
best 
approach however it works. Please let me know if you see any improvements:
at line ~233 I added:

var link = this.editorDoc.getElementsByTagName('a');                  
if(link) {
  for(i = 0; i < link.length; i++) {
    link[i].setAttribute('target', '_blank');
  }
}

This will append the target attribute to each link created in the text.

Original comment by zelaferr...@gmail.com on 4 Dec 2009 at 10:09

GoogleCodeExporter commented 8 years ago
More jQueried code:

$('a', this.editorDoc).attr('target', '_blank);

But I prefer to do it at server side.

Original comment by akzhan.a...@gmail.com on 5 Dec 2009 at 7:13

GoogleCodeExporter commented 8 years ago
And more smart one is:

$('a[href^="http://"]').attr('target', '_blank');

Original comment by akzhan.a...@gmail.com on 8 Dec 2009 at 11:59