Page 1 of 1

[Feature request] Adding rel-attribute to a-tag?

PostPosted: Tue Dec 12, 2006 8:23 pm
by DelTorro
I love this WYSIWYM editor and I am glad to see there is an editor which cares about semantics. I have one question though:

I guess a lot of people with XHTML strict websites use Javascript to open links in a new window (giving a-tags a rel-attribute, Javascript searches for links with this atrribute en puts a target="_blank" to it). Would it be possible to put this feature (giving a-tags a rel-attribute) in your editor? What's your opinion on this? Thanks in advance

Re: [Feature request] Adding rel-attribute to a-tag?

PostPosted: Tue Dec 12, 2006 10:22 pm
by jfh
DelTorro wrote:I love this WYSIWYM editor and I am glad to see there is an editor which cares about semantics. I have one question though:

I guess a lot of people with XHTML strict websites use Javascript to open links in a new window (giving a-tags a rel-attribute, Javascript searches for links with this atrribute en puts a target="_blank" to it). Would it be possible to put this feature (giving a-tags a rel-attribute) in your editor? What's your opinion on this? Thanks in advance

An easier solution is to create a new class for links, i.e. "targetblank", so the js code will check for links with this class.
You just need to customize the 'Classes' menu.

See http://trac.wymeditor.org/trac/wiki/Customization and http://trac.wymeditor.org/trac/wiki/FAQ

HTH,

Re: [Feature request] Adding rel-attribute to a-tag?

PostPosted: Wed Dec 13, 2006 6:18 pm
by DelTorro
jfh wrote:
DelTorro wrote:I love this WYSIWYM editor and I am glad to see there is an editor which cares about semantics. I have one question though:

I guess a lot of people with XHTML strict websites use Javascript to open links in a new window (giving a-tags a rel-attribute, Javascript searches for links with this atrribute en puts a target="_blank" to it). Would it be possible to put this feature (giving a-tags a rel-attribute) in your editor? What's your opinion on this? Thanks in advance

An easier solution is to create a new class for links, i.e. "targetblank", so the js code will check for links with this class.
You just need to customize the 'Classes' menu.

See http://trac.wymeditor.org/trac/wiki/Customization and http://trac.wymeditor.org/trac/wiki/FAQ

HTH,


Why didn't I think of that before? Thanx, I'm now sure to use this editor

PostPosted: Thu Dec 14, 2006 8:46 pm
by Daniel_R
Maybe this can be useful:

One of our clients absolutely wanted to have external links open in a separate window.

As I use Jquery, it was very easy to implement:

Code: Select all
   $(document).ready(function() {
      $("a[@href*='http://'],a[@class*='external']")
         .click(
            function(){
               window.open(this.href);
               return false;
            }
         );   
   });


The above code causes all external links, plus links with the class "external" to open in a new window.

The class "external" can be applied to links with WYMeditor if you simply configure the class panel as Jean-François explained.

URGENT !!!

PostPosted: Thu Nov 08, 2007 2:51 pm
by Fifi
Could you translate all this post in french and send the post in the french forum ? Please... My client want to have all external links open in a new window and I don't understand how to do this in WYNeditor.

Thx for your help !

PostPosted: Thu Nov 08, 2007 6:48 pm
by captain_torche
You just have to copy/paste the above code in the page which displays the final code.
You have to install jquery first.

-----
Tu dois juste recopier ce code dans la page qui affiche le code final.
Il faut par contre que tu aies Jquery.

PostPosted: Thu Nov 08, 2007 9:56 pm
by Fifi
I have Jquery (I think...). I've got a repertory called Jquery with the WYMeditor's repertory, is that it ?

What do you mean by "in the page which displays the final code" ?
Is it the page where I include WYMeditor ?
And where, in this page do I paste the code ?
Sorry, I don't know a lot about javascript...

_______________________________________________________________

J'ai Jquery, je pense... J'ai un dossier Jquery avec le dossier WYMeditor, c'est ça ?

Que veux tu dire par "dans la page qui affiche le code final" ?
Est-ce la page qui contient l'éditeur WYMeditor ?
A quel endroit de la page dois-je coller ce code ?
Désolé, je n'y connais pas grand chose en javascript...

PostPosted: Fri Nov 09, 2007 6:51 am
by captain_torche
You have to put the code in the page which will be displayed to visitors, it will be automatic.
In your Jquery folder, you should have got a file called jquery.js. In the page, you just have to make a link to this file, and therefore copy and paste the above code.

-----

Tu dois mettre le code dans la page qui sera affichée aux visiteurs, le traitement sera automatique.
Dans ton dossier Jquery, tu dois avoir un fichier jquery.js. Dans la page, tu dois juste faire un appel à ce fichier, avant d'y mettre le code susmentionné :
Code: Select all
<script type="text/javascript" src="wymeditor/jquery/jquery.js"></script>
<script type=text/javascript">
   $(document).ready(function() {
      $("a[@href*='http://'],a[@class*='external']")
         .click(
            function(){
               window.open(this.href);
               return false;
            }
         );   
   });
</script>
[/code]

PostPosted: Fri Nov 09, 2007 10:15 am
by Fifi
It doesn't work...
I paste the code in the header of my page :
________________________________________________________
ça ne marche pas... J'ai collé le code dans le header de ma page :

Code: Select all
<script type="text/javascript" src="jquery/jquery.js"></script>
<script type=text/javascript">
$(document).ready(function() {
$("a[@href*='http://'],a[@class*='external']")
.click(
   function(){
    window.open(this.href);
    return false;
   }
  );   
});
</script>
</head>


The Jquery repertory and my page are in the same repertory.
I have this link in my page :
___________________________________________________
Le répertoire Jquery et ma page sont dans le même répertoire.
J'ai ce lien dans ma page :
Code: Select all
<a class="external" title="chaletfilms.com" href="http://www.chaletfilms.com">www.chaletfilms.com</a>


Did I miss anything ?
I'm using jQuery 1.1.4 (the version downloaded with WYMeditor 0.4)
_____________________________________________________
Ai-je commis une erreur ou un oubli ?
J'ai la jQuery 1.1.4 (la version livrée avec WYMeditor 0.4)

Another question... about the classes. I add the class "external' in jquery.wymeditor.js file : (line 338)
___________________________________________________________
Autre question... à propos des classes. J'ai ajouter la classe "external" dans le fichier jquery.wymeditor.js : (ligne 338)
Code: Select all
classesItems:      [{'name': 'external', 'title': 'lien:externe', 'expr': 'a'}],


The option "lien:externe" appears. I try to apply this class for my link... nothing happen... Did I mistake or miss anything anywhere ?
___________________________________________________________
L'option "lien:externe" apparait bien. J'essaie de l'appliquer à mon lien... il ne se passe rien... Ai-je loupé quelque chose quelque part ?

Is there anyone who can help me in the french forum ?? It's hard to explain all my problems in english !!

Is there any text in french about installation and customization like in the Wiki ? (here)

Perhaps this topics should be moved in Support forum ??

PostPosted: Tue Nov 13, 2007 2:18 pm
by Fifi
Allo ? Nobody can help me ??

Re: [Feature request] Adding rel-attribute to a-tag?

PostPosted: Sat Nov 14, 2009 4:14 pm
by imcmanus6
Hello fifi, the code that was written in this thread did not work for me either, so I simply changed it to match my style sheet which was a.external { } to the following:
Code: Select all
$(document).ready(function() {
$("a.external")
.click(
   function(){
    window.open(this.href);
    return false;
   }
  );   
});


I hope that helps...Ian http://www.buzzherd.com/member/ian

Re: [Feature request] Adding rel-attribute to a-tag?

PostPosted: Fri Nov 27, 2009 6:07 pm
by Folken Laëneck
This is even simpler and work :
Code: Select all
$(document).ready( function() { $("a.external").attr('target', '_blank'); } );

Re: [Feature request] Adding rel-attribute to a-tag?

PostPosted: Wed Mar 31, 2010 3:24 pm
by christracy123
Folken Laëneck wrote:This is even simpler and work :
Code: Select all
$(document).ready( function() { $("a.external").attr('target', '_blank'); } );


This works.