1

I want to develop a custom javascript html editor. My starting point was: http://hypertextarea.sourceforge.net/

I understood how the mechanism works but the problem is that I cannot find the point where if I focus the iframe I have the cursor displayed.

Then if I press a key I see the letter entered there. Can you please explain me how this javascript shows the editor cursor and how it write in the iframe the characters that I write?

All javascript used by this editor is at http://hypertextarea.sourceforge.net/javascript/HyperTextArea.js

2 Answers 2

1

It is handled by the function enableDesignMode (line 755), which tries to turn on designMode for the <iframe>.

In other words, this is a browser feature and you can make an HTML page editable with nothing more than a single line of JS (or a single HTML attribute), but the library provides other niceties like the ability to format text and insert tables.

Sign up to request clarification or add additional context in comments.

Comments

0

Depending on exactly what you want: onKeyPress and onFocus

2 Comments

this editor generates me an iframe that has no function attached to this events. That's why I have no idee how it works.
This isn't what you asked for. You said "Can you please give me the javascript function that runs when I press a key or when I focus the iframe?" Create a standard input field, you'll note that it too has a cursor which blinks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.