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

  • Follow


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.

0
Reply johngilmer 1/14/2005 3:11:30 PM


johngilmer@yahoo.com wrote:

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

-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
0
Reply Martin 1/14/2005 4:36:32 PM


1 Replies
437 Views

(page loaded in 1.753 seconds)

Similiar Articles:













7/24/2012 2:35:34 AM


Reply: