Answer the question
In order to leave comments, you need to log in
Why doesn't execCommand('createLink') work in Firefox?
Good afternoon! I ask for help.
When I select the text, a toolbar appears above it with the "create link" button, by clicking on this button, input appears and the cursor immediately focuses on this input, I enter the link, press enter, and nothing happens in firefox (the link is not created), in chrome and safari all work fine, what could be the reason?
create events:
events:{
'click .link': 'toggleLink',
'keypress [name="link"]': 'setUrl'
},
toggleLink: function(e){
if(this.options.nodes.url){
this.$el.find('[name="link"]').val(this.options.nodes.url);
}
this.lastRange = window.getSelection().getRangeAt(0);
this.$el.find('[name="link"]').focus();
},
setUrl: function(e){
if(e.which == 13){
e.preventDefault();
this.$el.find('[name="link"]').blur();
window.getSelection().addRange(this.lastRange);
var url = $(e.currentTarget).val();
if(url.length > 0){
document.execCommand('createLink', false, url);
}else{
document.execCommand('unlink', false, null);
}
}
}
Answer the question
In order to leave comments, you need to log in
And what exactly is the problem - does the handler (setUrl method) not start, or is something wrong already happening in it?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question