hi all,
i m developing an html editor for my web page since i cannot trace out the enter key press for the available html editors for asp.net app. now i have done everything that i need with this editor but the execCommand doesnt work with IE, it works perfectly with FF. when i alerted myEditor.docume nt.queryCommand Enabled('Bold') [ for bold command ] i get false for IE where myEditor is the Iframe id which is used in editable mode. please help me...
i will post the whole code here.
//html part
[HTML]<IFRAME name="navoCHatE ditor" width="100%" height="100" onfocus="setKey pressHandler(wi ndow.frames.nav oCHatEditor, keyPressHandler )" ></IFRAME>
[/HTML]
//js part
[CODE=javascript]function keyPressHandler (evt) {
evt = evt || window.event;
if (evt) {
var keyCode = evt.charCode || evt.keyCode;
//output(evt.type + ': keyCode: ' + keyCode);
if(keyCode == '13')
alert('Enter Key pressed');
}
}
function setKeypressHand ler (windowOrFrame, keyHandler) {
var doc = windowOrFrame.d ocument;
if (doc) {
if (doc.addEventLi stener) {
doc.addEventLis tener(
'keypress',
keyHandler,
false
);
}
else if (doc.attachEven t) {
doc.attachEvent (
'onkeypress',
function () { keyHandler(wind owOrFrame.event ); }
);
}
else {
doc.onkeypress = keyHandler;
}
}
}
function initEditMode (frame) {
if (frame.document ) {
frame.document. designMode = 'on';
}
}
window.onload = function (evt) {
var editFrame = window.frames.n avoCHatEditor;
setKeypressHand ler(editFrame, keyPressHandler );
initEditMode(na voCHatEditor);
};
function RunCom(what) {
//*************** *************** ********
if (navoCHatEditor .document.query CommandEnabled( what) == true)
{
navoCHatEditor. focus();
navoCHatEditor. document.execCo mmand(what,fals e,"");
}
else
{
alert('command' + what + ' not enabled')
}
}
function ForeColor(col)
{
navoCHatEditor. document.execCo mmand("ForeColo r",0,col);
navoCHatEditor. focus();
}
/////[/CODE]
thanks,
ali
i m developing an html editor for my web page since i cannot trace out the enter key press for the available html editors for asp.net app. now i have done everything that i need with this editor but the execCommand doesnt work with IE, it works perfectly with FF. when i alerted myEditor.docume nt.queryCommand Enabled('Bold') [ for bold command ] i get false for IE where myEditor is the Iframe id which is used in editable mode. please help me...
i will post the whole code here.
//html part
[HTML]<IFRAME name="navoCHatE ditor" width="100%" height="100" onfocus="setKey pressHandler(wi ndow.frames.nav oCHatEditor, keyPressHandler )" ></IFRAME>
[/HTML]
//js part
[CODE=javascript]function keyPressHandler (evt) {
evt = evt || window.event;
if (evt) {
var keyCode = evt.charCode || evt.keyCode;
//output(evt.type + ': keyCode: ' + keyCode);
if(keyCode == '13')
alert('Enter Key pressed');
}
}
function setKeypressHand ler (windowOrFrame, keyHandler) {
var doc = windowOrFrame.d ocument;
if (doc) {
if (doc.addEventLi stener) {
doc.addEventLis tener(
'keypress',
keyHandler,
false
);
}
else if (doc.attachEven t) {
doc.attachEvent (
'onkeypress',
function () { keyHandler(wind owOrFrame.event ); }
);
}
else {
doc.onkeypress = keyHandler;
}
}
}
function initEditMode (frame) {
if (frame.document ) {
frame.document. designMode = 'on';
}
}
window.onload = function (evt) {
var editFrame = window.frames.n avoCHatEditor;
setKeypressHand ler(editFrame, keyPressHandler );
initEditMode(na voCHatEditor);
};
function RunCom(what) {
//*************** *************** ********
if (navoCHatEditor .document.query CommandEnabled( what) == true)
{
navoCHatEditor. focus();
navoCHatEditor. document.execCo mmand(what,fals e,"");
}
else
{
alert('command' + what + ' not enabled')
}
}
function ForeColor(col)
{
navoCHatEditor. document.execCo mmand("ForeColo r",0,col);
navoCHatEditor. focus();
}
/////[/CODE]
thanks,
ali
Comment