How can I change the insert/typeover mode of a text box?

J

johngilmer

By default, when I type into a text box, it inserts the text into the
existing text rather than overwriting the existing text. If I hit the
"insert" key on my keyboard, it switches the mode to over-writing the
text in the box. But when I refresh the page, it returns to inserting
the text. I want my text boxes to be in the overwrite mode by default.
Is there a way to do this in html or javascript. The solution only
needs to work for IE.
Thanks in advance.
 
M

Martin Honnen

By default, when I type into a text box, it inserts the text into the
existing text rather than overwriting the existing text. If I hit the
"insert" key on my keyboard, it switches the mode to over-writing the
text in the box. But when I refresh the page, it returns to inserting
the text. I want my text boxes to be in the overwrite mode by default.
Is there a way to do this in html or javascript. The solution only
needs to work for IE.

For IE Windows it seems to work to call
document.execCommand('OverWrite', false, true)
to enable overwrite mode for text controls on the page and
document.execCommand('OverWrite', false, false)
to switch it off.
execCommand and its command strings (e.g. 'OverWrite') are documented on
http://msdn.microsoft.com/.
With IE 5.5 and IE 6 you can have editable HTML controls too (e.g. with
<div contenteditable="true">
I have not tested but I expect calling
document.execCommand('OverWrite', false, true)
will switch on overwrite mode for those editable areas too so be careful
on when/where you call the command.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,147
Latest member
CarenSchni
Top