Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Rich text editor

Reply
Thread Tools

Rich text editor

 
 
Prasad
Guest
Posts: n/a
 
      11-24-2006

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,

 
Reply With Quote
 
 
 
 
Prasad
Guest
Posts: n/a
 
      11-25-2006

Prasad wrote:
> 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
..

 
Reply With Quote
 
 
 
 
Prasad
Guest
Posts: n/a
 
      11-27-2006

Prasad wrote:
> Prasad wrote:
> > 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 ???

 
Reply With Quote
 
marss
Guest
Posts: n/a
 
      11-27-2006

Prasad wrote:

> 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'");
});


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


 
Reply With Quote
 
Dylan Parry
Guest
Posts: n/a
 
      11-27-2006
Prasad wrote:
> 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.
 
Reply With Quote
 
Prasad
Guest
Posts: n/a
 
      11-27-2006

marss wrote:
> Prasad wrote:
>
> > 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!




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


 
Reply With Quote
 
Prasad
Guest
Posts: n/a
 
      11-27-2006

Dylan Parry wrote:
> Prasad wrote:
> > 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..

> 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.


 
Reply With Quote
 
Prasad
Guest
Posts: n/a
 
      11-28-2006

Prasad wrote:
> marss wrote:
> > Prasad wrote:
> >
> > > 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!
>



Sorry ! it's coming for mozilla too
I used event type "onkeypress" instead of " keypress"
>


Thanx alot for helping me out
>
>
> > > }
> > > displayEditor("editor", "html", 250, 200) ;
> > > </script>
> > >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rich:dataTable - rich:dataScroller Hollow Quincy Java 5 01-02-2012 08:59 PM
Recommended rich text editor Eirik Eldorsen ASP .Net 2 01-18-2005 01:27 PM
Need suggestions: Best Rich Text Editor for ASP.NET VB Programmer ASP .Net 2 12-29-2004 01:45 AM
Question: Rich Text Editor and HTML message body VB Programmer ASP .Net 2 12-15-2004 11:09 PM
OT: Rich Text Box editor (IE object) Marina ASP .Net 1 07-11-2003 05:05 PM



Advertisments