Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #12486

Restoring Control

From Gene Wirchenko <genew@ocis.net>
Newsgroups comp.lang.javascript
Subject Restoring Control
Date 2012-03-07 17:11 -0800
Organization A noiseless patient Spider
Message-ID <9p1gl7998joev9a2b4snt87bticgsr88lm@4ax.com> (permalink)

Show all headers | View raw


Dear JavaScripters:

     In my form handler, I have a form reset.  This is confirmed using
confirm().  That causes the focus to move.  If the reset is confirmed,
then it is no matter: the form will be reinitialised.

     If the reset is denied, then I restore focus to the control that
had it just before then.  Unfortunately, this causes the onfocus code
to execute which .select()s the entire value (which is usually what is
wanted).

     What I would like to have happen in this case is that the
previous status of the control is restored.  The previous status that
I am concerned with is cursor position and what text is selected.

     How can I do this?  Is there a browser-independent way to do
this?

     What I have found seems to indicate that IE and Firefox have
different ways, and I am not sure exactly what the code does.

     Note that I am not concerned with getting said data but restoring
it.

     A good pointer would be very much appreciated.

     I have found a way that appears to work by using a couple of
globals, but I may need to be able to select very specific parts of a
control value so I am still interested.

Sincerely,

Gene Wirchenko

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Restoring Control Gene Wirchenko <genew@ocis.net> - 2012-03-07 17:11 -0800
  Re: Restoring Control Scott Sauyet <scott.sauyet@gmail.com> - 2012-03-08 04:39 -0800
    Re: Restoring Control Gene Wirchenko <genew@ocis.net> - 2012-03-08 08:17 -0800
      Re: Restoring Control Scott Sauyet <scott.sauyet@gmail.com> - 2012-03-10 17:45 -0800
        Re: Restoring Control Gene Wirchenko <genew@ocis.net> - 2012-03-10 23:53 -0800
          Re: Restoring Control Mike Duffy <Use_guestbook_page@website.in.sig> - 2012-03-11 16:54 +0000
            Re: Restoring Control Gene Wirchenko <genew@ocis.net> - 2012-03-11 20:52 -0700
              Re: Restoring Control Dr J R Stockton <reply1211@merlyn.demon.co.uk.not.invalid> - 2012-03-13 18:36 +0000
                Re: Restoring Control Gene Wirchenko <genew@ocis.net> - 2012-03-13 19:49 -0700
    Re: Restoring Control David Mark <dmark.cinsoft@gmail.com> - 2012-03-12 16:55 -0700

csiph-web