Connecting Tech Pros Worldwide Forums | Help | Site Map

Rich text editor

Prasad
Guest
 
Posts: n/a
#1: Nov 24 '06

Hi all, I am trying to develop a simple rich text editor
I do only require bold, itlaic, underline..

The code for IE is

<script>
function displayEditor(editor, html, width, height)
{

document.writeln('<iframe id="' + editor + '" name="' + editor +
'" width="' + width + 'px" height="' + height + 'px"></iframe>');

var mainContent= '<html id="' + editor + '"><head></head><body
onkeypress=alert("Hi")>"' + html + '"</body></html>' ;
var edit = document.getElementById(editor).contentWindow.docu ment;

edit.write(mainContent);

edit.designMode = "On" ;

}
displayEditor("editor", "html", 250, 200) ;
</script>

"You can use Ctrl+B to bold, Ctrl+U to underline, Ctrl+I for Italic "

Its working fine but I wanted to know which key is pressed .
For this, I have written onkeypress event in the body tag .
But that event is not geing fired .

So what should I do here to know which key is pressed ?

Please help me out ..

Thanx in advance,


Prasad
Guest
 
Posts: n/a
#2: Nov 25 '06

re: Rich text editor



Prasad wrote:
Quote:
Hi all, I am trying to develop a simple rich text editor
I do only require bold, itlaic, underline..
>
The code for IE is
>
<script>
function displayEditor(editor, html, width, height)
{
>
document.writeln('<iframe id="' + editor + '" name="' + editor +
'" width="' + width + 'px" height="' + height + 'px"></iframe>');
>
var mainContent= '<html id="' + editor + '"><head></head><body
onkeypress=alert("Hi")>"' + html + '"</body></html>' ;
var edit = document.getElementById(editor).contentWindow.docu ment;
>
edit.write(mainContent);
>
edit.designMode = "On" ;
>
}
displayEditor("editor", "html", 250, 200) ;
</script>
>
"You can use Ctrl+B to bold, Ctrl+U to underline, Ctrl+I for Italic "
>
Its working fine but I wanted to know which key is pressed .
For this, I have written onkeypress event in the body tag .
But that event is not geing fired .
>
So what should I do here to know which key is pressed ?
>
Please help me out ..
>
Thanx in advance,

Please help me out here , I could not move anywhere until & unless I
solve this ..
If what I required is not possible , can any suggest a new method
which creates a simple editor and helps to know which is key is pressed
..

Prasad
Guest
 
Posts: n/a
#3: Nov 27 '06

re: Rich text editor



Prasad wrote:
Quote:
Prasad wrote:
Quote:
Hi all, I am trying to develop a simple rich text editor
I do only require bold, itlaic, underline..

The code for IE is

<script>
function displayEditor(editor, html, width, height)
{

document.writeln('<iframe id="' + editor + '" name="' + editor +
'" width="' + width + 'px" height="' + height + 'px"></iframe>');

var mainContent= '<html id="' + editor + '"><head></head><body
onkeypress=alert("Hi")>"' + html + '"</body></html>' ;
var edit = document.getElementById(editor).contentWindow.docu ment;

edit.write(mainContent);

edit.designMode = "On" ;

}
displayEditor("editor", "html", 250, 200) ;
</script>

"You can use Ctrl+B to bold, Ctrl+U to underline, Ctrl+I for Italic "

Its working fine but I wanted to know which key is pressed .
For this, I have written onkeypress event in the body tag .
But that event is not geing fired .

So what should I do here to know which key is pressed ?

Please help me out ..

Thanx in advance,
>
>
Please help me out here , I could not move anywhere until & unless I
solve this ..
If what I required is not possible , can any suggest a new method
which creates a simple editor and helps to know which key is pressed
.
Hi all, any workaround here ??
Or can I atleast know that "Enter key " is pressed while entering data
into the editor ???

marss
Guest
 
Posts: n/a
#4: Nov 27 '06

re: Rich text editor



Prasad wrote:
Quote:
edit.write(mainContent);
>
edit.designMode = "On" ;
>
Hi,
Try to add here next code:
edit.attachEvent("onkeypress", function(event){
if (event.keyCode == 13)
alert("You pressed 'Enter'");
});

Quote:
}
displayEditor("editor", "html", 250, 200) ;
</script>
>
Dylan Parry
Guest
 
Posts: n/a
#5: Nov 27 '06

re: Rich text editor


Prasad wrote:
Quote:
Hi all, I am trying to develop a simple rich text editor
Are you doing this because you require a rich text editor, and don't
know of any existing ones? Or are you doing this because you *want* to
do it?

If the answer to the first question is "yes", then I'd suggest you don't
reinvent the wheel ;)

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

Programming, n: A pastime similar to banging one's head
against a wall, but with fewer opportunities for reward.
Prasad
Guest
 
Posts: n/a
#6: Nov 27 '06

re: Rich text editor



marss wrote:
Quote:
Prasad wrote:
>
Quote:
edit.write(mainContent);

edit.designMode = "On" ;
>
Hi,
Try to add here next code:
edit.attachEvent("onkeypress", function(event){
if (event.keyCode == 13)
alert("You pressed 'Enter'");
});
>
>
Ohhhhhh
It's working................
I am very much thankful to you ..
Its working in IE
and for Mozilla I changed to :
document.getElementById(editor).contentDocument.ad dEventListener("onkeypress",
function(event){
if (event.keyCode == 13)
alert("You pressed 'Enter'");
},false);
But its not working ..
Any thing wrong in the code?????

Thanx once again!



Quote:
Quote:
}
displayEditor("editor", "html", 250, 200) ;
</script>
Prasad
Guest
 
Posts: n/a
#7: Nov 27 '06

re: Rich text editor



Dylan Parry wrote:
Quote:
Prasad wrote:
Quote:
Hi all, I am trying to develop a simple rich text editor
>
Are you doing this because you require a rich text editor, and don't
know of any existing ones? Or are you doing this because you *want* to
do it?
>
If the answer to the first question is "yes", then I'd suggest you don't
reinvent the wheel ;)
>
--
Yes .. I require a rich text editor and but also I know of existing
ones ..
But I want my editor to be very simple as above..(FYI, I am not
reinventing the wheel .. I took the the existing code and modified it
as above to make it simple)..

So I "want" to do this..
Quote:
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk
>
Programming, n: A pastime similar to banging one's head
against a wall, but with fewer opportunities for reward.
Prasad
Guest
 
Posts: n/a
#8: Nov 28 '06

re: Rich text editor



Prasad wrote:
Quote:
marss wrote:
Quote:
Prasad wrote:
Quote:
edit.write(mainContent);
>
edit.designMode = "On" ;
>
Hi,
Try to add here next code:
edit.attachEvent("onkeypress", function(event){
if (event.keyCode == 13)
alert("You pressed 'Enter'");
});
>
Ohhhhhh
It's working................
I am very much thankful to you ..
Its working in IE
and for Mozilla I changed to :
document.getElementById(editor).contentDocument.ad dEventListener("onkeypress",
function(event){
if (event.keyCode == 13)
alert("You pressed 'Enter'");
},false);
But its not working ..
Any thing wrong in the code?????
>
Quote:
Thanx once again!
>

Sorry ! it's coming for mozilla too
I used event type "onkeypress" instead of " keypress"
Quote:
>
Thanx alot for helping me out
Quote:
>
>
Quote:
Quote:
}
displayEditor("editor", "html", 250, 200) ;
</script>
>
Closed Thread