i am trying to use fckeditor for a chat.
suppose http://abc.com/index.php
on index.php i have a function defined which works for ajax. ( call_ajax() )
now all i want it when i press enter in the fckeditor box it calls a function defined in index.php
so i have copied this code in fckconfig.js
function DENOnKeyDownFunction(){ [color=#FF0000]call_ajax();[/color] } function DenIE_OnKeyDown(){ var e = FCK.EditorWindow.event ; var alreadyRun = false; // alert(e.keyCode); switch ( e.keyCode ){ case 13 : // ENTER if ( !(e.ctrlKey || e.altKey || e.shiftKey) ){ e.cancelBubble = true ; e.returnValue = false; if (alreadyRun == false) { DENOnKeyDownFunction(); alreadyRun = true } return false; }else{ return true; } break ; } } var DenGecko_OnKeyDown = function(e) { var alreadyRun = false; // checks if enter key alone was pressed, and if so, say hello! if (e.which == 13 && !e.shiftKey && !e.ctrlKey && !e.altKey) { e.preventDefault(); e.stopPropagation(); if (alreadyRun == false) { DENOnKeyDownFunction(); alreadyRun = true } return false; } return true }; function FCKKeyPress_SetListeners() { if (document.all) { // If Internet Explorer. FCK.EditorDocument.attachEvent("onkeydown", DenIE_OnKeyDown ) ; }else{ // If Gecko. FCK.EditorDocument.addEventListener( 'keypress', DenGecko_OnKeyDown, true ) ; } } FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKKeyPress_SetListeners ) ;
Re: Javascript function issue
all i need to do was call the function as
parent.call_ajax();
worked