Hi,
I have created a plugin that creates or changes a hyperlink.
But I can't change the href attribute of an existing hyperlink, it remains unchanged.
Other attributes like "target" do change.
My code:
I have created a plugin that creates or changes a hyperlink.
But I can't change the href attribute of an existing hyperlink, it remains unchanged.
Other attributes like "target" do change.
My code:
(function(){
var a = {
exec:function(editor){
var element = null;
var selection = editor.getSelection();
if ( ( element = CKEDITOR.plugins.link.getSelectedLink( editor ) ) && element.hasAttribute( 'href' ) )
selection.selectElement( element );
if (!element) {
// no problem here
} else {
// existing hyperlink
element.setHtml ( 'Well that works' );
element.setAttributes ( { 'href' : 'mailto:from@button.com', 'target': '_blank' });
}
}
},
b='cmslink';
CKEDITOR.plugins.add(b,{
init:function(editor){
editor.addCommand(b,a);
editor.ui.addButton('cmslink',{
label:'CMS hyperlink',
icon: this.path + 'image.gif',
command:b
});
}
});
})(); 
Re: element.setAttribute( 'href' , '#anything') won't apply
Re: element.setAttribute( 'href' , '#anything') won't apply
Re: element.setAttribute( 'href' , '#anything') won't apply