Hi everyone,
I would like to work with FckEditor in a Chat tool, using the text editor to send messages (see attached gif).
I want to press the ENTER button and capture an event (send the message). After sending the message, the editor should be cleaned up
and the focus back to the initial position.
I disable the following properties in fckconfig.js file:
FCKConfig.EnterMode="br";
FCKConfig.ShiftEnterMode="p";
In my HTML page, I have the following code:
function FCKeditor_OnComplete(editorInstance) {
if (document.all) { // This works to Internet Explorer
editorInstance.Focus();
editorInstance.Events.AttachEvent('OnSelectionChange',
FckEditorKeyDown );
}
else { //This should work to Firefox, but it doesn't
editorInstance.Focus();
editorInstance.Events.AttachEvent('OnSelectionChange',
FckEditorKeyDown, true );
}
}
function FckEditorKeyDown(editorInstance){
var e = editorInstance.EditorWindow.event;
if (e.keyCode == 13) {
var message = editorInstance.GetData();
alert('Message sent!');
document.getElementById('form').submit();
}
}
It works properly to Internet Explorer, but NOT to Firefox and
other browsers. Is there a solution to Firefox and others?
Best regards,
Leandro.
I would like to work with FckEditor in a Chat tool, using the text editor to send messages (see attached gif).
I want to press the ENTER button and capture an event (send the message). After sending the message, the editor should be cleaned up
and the focus back to the initial position.
I disable the following properties in fckconfig.js file:
FCKConfig.EnterMode="br";
FCKConfig.ShiftEnterMode="p";
In my HTML page, I have the following code:
function FCKeditor_OnComplete(editorInstance) {
if (document.all) { // This works to Internet Explorer
editorInstance.Focus();
editorInstance.Events.AttachEvent('OnSelectionChange',
FckEditorKeyDown );
}
else { //This should work to Firefox, but it doesn't
editorInstance.Focus();
editorInstance.Events.AttachEvent('OnSelectionChange',
FckEditorKeyDown, true );
}
}
function FckEditorKeyDown(editorInstance){
var e = editorInstance.EditorWindow.event;
if (e.keyCode == 13) {
var message = editorInstance.GetData();
alert('Message sent!');
document.getElementById('form').submit();
}
}
It works properly to Internet Explorer, but NOT to Firefox and
other browsers. Is there a solution to Firefox and others?
Best regards,
Leandro.