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


Groups > comp.lang.javascript > #18663 > unrolled thread

Setting focus

Started byTim Slattery <Slattery_T@bls.gov>
First post2013-02-28 14:30 -0500
Last post2013-03-30 17:55 +0100
Articles 20 on this page of 31 — 7 participants

Back to article view | Back to comp.lang.javascript


Contents

  Setting focus Tim Slattery <Slattery_T@bls.gov> - 2013-02-28 14:30 -0500
    Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-28 20:50 +0100
      Re: Setting focus Tim Slattery <Slattery_T@bls.gov> - 2013-02-28 16:05 -0500
        Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-28 22:17 +0100
          Re: Setting focus Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-02-28 23:16 +0100
            Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-28 23:36 +0100
              Re: Setting focus Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-03-01 08:21 +0100
                Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-01 13:10 +0100
            Re: Setting focus "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-02-28 23:37 +0100
              Re: Setting focus Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-03-01 08:18 +0100
                Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-01 13:12 +0100
                  Re: Setting focus Bernd Nawothnig <Bernd.Nawothnig@t-online.de> - 2013-03-02 15:16 +0100
          Re: Setting focus Scott Sauyet <scott.sauyet@gmail.com> - 2013-03-21 20:06 -0700
            Re: Setting focus Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-03-22 10:03 +0100
              Re: Setting focus Tim Slattery <Slattery_T@bls.gov> - 2013-03-22 08:53 -0400
                Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-23 15:09 +0100
              Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-23 15:07 +0100
                Re: Setting focus Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-03-24 12:38 +0100
                  Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-24 13:42 +0100
                    Re: Setting focus Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-03-24 13:54 +0100
            Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-23 15:04 +0100
              Re: Setting focus Scott Sauyet <scott.sauyet@gmail.com> - 2013-03-23 17:35 -0700
                Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-24 10:41 +0100
                  Re: Setting focus Scott Sauyet <scott.sauyet@gmail.com> - 2013-03-24 16:42 -0700
                    Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-30 14:27 +0100
                      Re: Setting focus Scott Sauyet <scott.sauyet@gmail.com> - 2013-03-30 09:25 -0700
                        Re: Setting focus Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-30 19:50 +0100
                          Re: Setting focus Scott Sauyet <scott.sauyet@gmail.com> - 2013-03-30 17:11 -0700
                Re: Setting focus Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-03-30 01:02 +0100
                  Re: Setting focus Scott Sauyet <scott.sauyet@gmail.com> - 2013-03-30 09:17 -0700
                    Re: Setting focus "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-30 17:55 +0100

Page 1 of 2  [1] 2  Next page →


#18663 — Setting focus

FromTim Slattery <Slattery_T@bls.gov>
Date2013-02-28 14:30 -0500
SubjectSetting focus
Message-ID<gkbvi8t9r9n3gob0gm3tiofn8rbif8naa9@4ax.com>
My function creates a new <input type=file> element. It then attempts
to set the focus on the new element. Like this:

o = document.getElementById("putithere");
o.innerHTML = '<input type="file" id="newbox" />';
document.getElementById("newbox").focus();

"putithere" is the id of an empty <div>. The id of the new element is
dynamically generated in the real function, but the test function
works the same way.

In IE and Chrome, this works just fine. The new box appears and it has
the focus. But in Firefox the focus stays on the button that launched
the function! Can I make Firefox handle this like IE and Chrome?

-- 
Tim Slattery
Slattery_T@bls.gov

[toc] | [next] | [standalone]


#18664

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-02-28 20:50 +0100
Message-ID<2471865.AAA9jsC1C5@PointedEars.de>
In reply to#18663
Tim Slattery wrote:

> My function creates a new <input type=file> element. It then attempts
> to set the focus on the new element. Like this:
> 
> o = document.getElementById("putithere");
> o.innerHTML = '<input type="file" id="newbox" />';
> document.getElementById("newbox").focus();
> 
> "putithere" is the id of an empty <div>. The id of the new element is
> dynamically generated in the real function, but the test function
> works the same way.
> 
> In IE and Chrome, this works just fine. The new box appears and it has
> the focus. But in Firefox the focus stays on the button that launched
> the function! Can I make Firefox handle this like IE and Chrome?

Probably not.  But avoiding “innerHTML” could help there; it would also be 
more efficient.  You looked and there were no relevant errors in the 
console, yes?

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18665

FromTim Slattery <Slattery_T@bls.gov>
Date2013-02-28 16:05 -0500
Message-ID<2fhvi8djf47mg171ogdejn3akiam4s10ds@4ax.com>
In reply to#18664
Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote:

>Tim Slattery wrote:
>
>> My function creates a new <input type=file> element. It then attempts
>> to set the focus on the new element. Like this:
>> 
>> o = document.getElementById("putithere");
>> o.innerHTML = '<input type="file" id="newbox" />';
>> document.getElementById("newbox").focus();
>> 
>> "putithere" is the id of an empty <div>. The id of the new element is
>> dynamically generated in the real function, but the test function
>> works the same way.
>> 
>> In IE and Chrome, this works just fine. The new box appears and it has
>> the focus. But in Firefox the focus stays on the button that launched
>> the function! Can I make Firefox handle this like IE and Chrome?
>
>Probably not. But avoiding “innerHTML” could help there; it would also be 
>more efficient. You looked and there were no relevant errors in the 
>console, yes?

Right, no errors. But I found the solution:

field = document.getElementById("newbox");
setTimeout("field.focus()", 50);

Works in all three browsers.

-- 
Tim Slattery
Slattery_T@bls.gov

[toc] | [prev] | [next] | [standalone]


#18666

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-02-28 22:17 +0100
Message-ID<2754930.5lBmWyc64D@PointedEars.de>
In reply to#18665
Tim Slattery wrote:

> Thomas 'PointedEars' Lahn <PointedEars@web.de> wrote:
>>Tim Slattery wrote:
>>> My function creates a new <input type=file> element. It then attempts
>>> to set the focus on the new element. Like this:
>>> 
>>> o = document.getElementById("putithere");
>>> o.innerHTML = '<input type="file" id="newbox" />';
>>> document.getElementById("newbox").focus();
>>> 
>>> "putithere" is the id of an empty <div>. The id of the new element is
>>> dynamically generated in the real function, but the test function
>>> works the same way.
>>> 
>>> In IE and Chrome, this works just fine. The new box appears and it has
>>> the focus. But in Firefox the focus stays on the button that launched
>>> the function! Can I make Firefox handle this like IE and Chrome?
>>
>> Probably not. But avoiding “innerHTML” could help there; it would also be
>> more efficient. You looked and there were no relevant errors in the
>> console, yes?
> 
> Right, no errors.

OK.

> But I found the solution:

No, you found a *temporary* *workaround*.

> field = document.getElementById("newbox");

  var field = …

> setTimeout("field.focus()", 50);

  var t = window.setTimeout(function () {
    field.focus();
    window.clearTimeout(t);
    field = null;
    t = null;
  }, 50);

That is, of course, also only a temporary workaround.

> Works in all three browsers.
           ^^^^^^^^^^^^^^^^^^
Apparently you have a lot to learn.  If you want to be successful in this 
field, you should start thinking in terms of layout engines and DOM 
implementations instead of browsers.  There are more than three different 
browsers anyway.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18667

FromCezary Tomczyk <cezary.tomczyk@gmail.com>
Date2013-02-28 23:16 +0100
Message-ID<kgokv7$du5$1@speranza.aioe.org>
In reply to#18666
W dniu 2013-02-28 22:17, Thomas 'PointedEars' Lahn pisze:
[...]
>    var t = window.setTimeout(function () {
>      field.focus();
>      window.clearTimeout(t);
>      field = null;
>      t = null;
>    }, 50);

Why here is window.clearTimeout(t);?

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

[toc] | [prev] | [next] | [standalone]


#18668

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-02-28 23:36 +0100
Message-ID<1590776.uEoHKtjbnQ@PointedEars.de>
In reply to#18667
Cezary Tomczyk wrote:

> Thomas 'PointedEars' Lahn pisze:
> [...]
>>    var t = window.setTimeout(function () {
>>      field.focus();
>>      window.clearTimeout(t);
>>      field = null;
>>      t = null;
>>    }, 50);
> 
> Why here is window.clearTimeout(t);?

Because you clean up after yourself.  Usually you should also clear timeouts 
onunload (see my website), but this one might be short enough so that 
clearing when it is done would suffice.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18676

FromCezary Tomczyk <cezary.tomczyk@gmail.com>
Date2013-03-01 08:21 +0100
Message-ID<kgpkuf$ji7$1@speranza.aioe.org>
In reply to#18668
W dniu 2013-02-28 23:36, Thomas 'PointedEars' Lahn pisze:
> Cezary Tomczyk wrote:
>
>> Thomas 'PointedEars' Lahn pisze:
>> [...]
>>>     var t = window.setTimeout(function () {
>>>       field.focus();
>>>       window.clearTimeout(t);
>>>       field = null;
>>>       t = null;
>>>     }, 50);
>>
>> Why here is window.clearTimeout(t);?
>
> Because you clean up after yourself.  Usually you should also clear timeouts
> onunload (see my website), but this one might be short enough so that
> clearing when it is done would suffice.

setTimeout returns and identifier which can be used to cancel the 
evaluation. In this case setTimeout is evaluate only once and no more. I 
do not see benefits by using clearTimeout here.

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

[toc] | [prev] | [next] | [standalone]


#18680

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-03-01 13:10 +0100
Message-ID<1459418.17r1LNzz15@PointedEars.de>
In reply to#18676
Cezary Tomczyk wrote:

> W dniu 2013-02-28 23:36, Thomas 'PointedEars' Lahn pisze:
>> Cezary Tomczyk wrote:
>>> Thomas 'PointedEars' Lahn pisze:
>>> [...]
>>>>     var t = window.setTimeout(function () {
>>>>       field.focus();
>>>>       window.clearTimeout(t);
>>>>       field = null;
>>>>       t = null;
>>>>     }, 50);
>>>
>>> Why here is window.clearTimeout(t);?
>>
>> Because you clean up after yourself.  Usually you should also clear
>> timeouts onunload (see my website), but this one might be short enough so
>> that clearing when it is done would suffice.
> 
> setTimeout returns and identifier which can be used to cancel the
> evaluation.

In a manner of speaking.

> In this case setTimeout is evaluate only once and no more. I
> do not see benefits by using clearTimeout here.

Your problem.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18669

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-02-28 23:37 +0100
Message-ID<XnsA175F03EDDEB5eejj99@194.109.133.133>
In reply to#18667
Cezary Tomczyk wrote on 28 feb 2013 in comp.lang.javascript:

> W dniu 2013-02-28 22:17, Thomas 'PointedEars' Lahn pisze:
> [...]
>>    var t = window.setTimeout(function () {
>>      field.focus();
>>      window.clearTimeout(t);
>>      field = null;
>>      t = null;
>>    }, 50);
> 
> Why here is window.clearTimeout(t);?

Not needed, the timeout is cleared on firing.

There is no need te set the field variable to null.

There is no need te set the t variable to null.

There is no need to name the setTimeout(),
if you don't want to prevent firing it,
so the variable t is not needed at all.


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#18675

FromCezary Tomczyk <cezary.tomczyk@gmail.com>
Date2013-03-01 08:18 +0100
Message-ID<kgpko7$iq0$1@speranza.aioe.org>
In reply to#18669
W dniu 2013-02-28 23:37, Evertjan. pisze:
> Cezary Tomczyk wrote on 28 feb 2013 in comp.lang.javascript:
>
>> W dniu 2013-02-28 22:17, Thomas 'PointedEars' Lahn pisze:
>> [...]
>>>     var t = window.setTimeout(function () {
>>>       field.focus();
>>>       window.clearTimeout(t);
>>>       field = null;
>>>       t = null;
>>>     }, 50);
>>
>> Why here is window.clearTimeout(t);?
>
> Not needed, the timeout is cleared on firing.
>
> There is no need te set the field variable to null.
>
> There is no need te set the t variable to null.
>
> There is no need to name the setTimeout(),
> if you don't want to prevent firing it,
> so the variable t is not needed at all.

Exactly I think in the same way. That's why I asked.

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

[toc] | [prev] | [next] | [standalone]


#18681

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-03-01 13:12 +0100
Message-ID<10568013.HPcdpVcOZq@PointedEars.de>
In reply to#18675
Cezary Tomczyk wrote:

> W dniu 2013-02-28 23:37, Evertjan. pisze:
>> Cezary Tomczyk wrote on 28 feb 2013 in comp.lang.javascript:
>>> W dniu 2013-02-28 22:17, Thomas 'PointedEars' Lahn pisze:
>>> [...]
>>>>     var t = window.setTimeout(function () {
>>>>       field.focus();
>>>>       window.clearTimeout(t);
>>>>       field = null;
>>>>       t = null;
>>>>     }, 50);
>>>
>>> Why here is window.clearTimeout(t);?
>>
>> Not needed, the timeout is cleared on firing.

You probably have evidence to back that up.

>> There is no need te set the field variable to null.

Yes, there is.  man Closure

>> There is no need te set the t variable to null.

Yes, there is.  man Reliability

>> There is no need to name the setTimeout(),
>> if you don't want to prevent firing it,
>> so the variable t is not needed at all.

Yes, there is.  man Repetition

> Exactly I think in the same way. That's why I asked.

And why you expect a good answer from him of all people?
 
-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18690

FromBernd Nawothnig <Bernd.Nawothnig@t-online.de>
Date2013-03-02 15:16 +0100
Message-ID<p6e90a-cdd.ln1@bernd.nawothnig.dialin.t-online.de>
In reply to#18681
On 2013-03-01, Thomas 'PointedEars' Lahn wrote:
> Cezary Tomczyk wrote:
>
>> W dniu 2013-02-28 23:37, Evertjan. pisze:
>>> Cezary Tomczyk wrote on 28 feb 2013 in comp.lang.javascript:
>>>> W dniu 2013-02-28 22:17, Thomas 'PointedEars' Lahn pisze:
>>>> [...]
>>>>>     var t = window.setTimeout(function () {
>>>>>       field.focus();
>>>>>       window.clearTimeout(t);
>>>>>       field = null;
>>>>>       t = null;
>>>>>     }, 50);
>>>>
>>>> Why here is window.clearTimeout(t);?
>>>
>>> Not needed, the timeout is cleared on firing.
>
> You probably have evidence to back that up.
>
>>> There is no need te set the field variable to null.
>
> Yes, there is.  man Closure

OMG

Si tacuisses, philosophus mansisses.




Bernd

-- 
no time toulouse

[toc] | [prev] | [next] | [standalone]


#18966

FromScott Sauyet <scott.sauyet@gmail.com>
Date2013-03-21 20:06 -0700
Message-ID<91cef6bd-0cf0-4450-b9dd-cb96c95cd9ad@u7g2000yqg.googlegroups.com>
In reply to#18666
Thomas 'PointedEars' Lahn wrote:
> Tim Slattery wrote:

>> But I found the solution:
>
> No, you found a *temporary* *workaround*.

ACK

>> field = document.getElementById("newbox");
>
>   var field = …
>
>> setTimeout("field.focus()", 50);
>
>   var t = window.setTimeout(function () {
>     field.focus();
>     window.clearTimeout(t);
>     field = null;
>     t = null;
>   }, 50);
>
> That is, of course, also only a temporary workaround.

Of course, but if you're going down this path, why not something as
simple as

    (function() {
        var field = …;
        window.setTimeout(function () {
            field.focus();
        }, 50);
    }());

Your code suggests of course that the function associated with the
setTimeout call will live well beyond the time when it's fired, and so
the properties in the related closure should be cleaned up.  I've
never run across that.  Do you have any demonstrations of it or
references that discuss it?  I have my doubts because it seems to me
that if it were the case, pages with heavy animations would often
quickly overload the memory.  But I'd love to hear more.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#18969

FromCezary Tomczyk <cezary.tomczyk@gmail.com>
Date2013-03-22 10:03 +0100
Message-ID<kih6oj$io3$1@speranza.aioe.org>
In reply to#18966
W dniu 2013-03-22 04:06, Scott Sauyet pisze:
[...]
>      (function() {
>          var field = …;
>          window.setTimeout(function () {
>              field.focus();
>          }, 50);
>      }());

Does setTimeout for setting focus is still needed? I remember when this 
was used for some old version of Firefox.

On the other hand I saw something like:

field.blur().focus();

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

[toc] | [prev] | [next] | [standalone]


#18970

FromTim Slattery <Slattery_T@bls.gov>
Date2013-03-22 08:53 -0400
Message-ID<gskok89p7j5h1c11kola26c5spb7ici4j1@4ax.com>
In reply to#18969
Cezary Tomczyk <cezary.tomczyk@gmail.com> wrote:

>Does setTimeout for setting focus is still needed? I remember when this 
>was used for some old version of Firefox.

That's a possibility. Here at work I'm stuck with the ESR version of
Firefox, which is at version 10.0.12. It's possible that the problem
no longer exists on the latest Firefox, I never tested it on my home
machine.

We also run IE8. We're not supposed to have Chrome at all, but it
installs just fine. So I have one up-to-date browser.

-- 
Tim Slattery
Slattery_T@bls.gov

[toc] | [prev] | [next] | [standalone]


#18978

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-03-23 15:09 +0100
Message-ID<4400671.EpOvZkifZF@PointedEars.de>
In reply to#18970
Tim Slattery wrote:

> Cezary Tomczyk <cezary.tomczyk@gmail.com> wrote:
>> Does setTimeout for setting focus is still needed? I remember when this
>> was used for some old version of Firefox.
> 
> That's a possibility. Here at work I'm stuck with the ESR version of
> Firefox, which is at version 10.0.12. It's possible that the problem
> no longer exists on the latest Firefox, […]

It's not a bug; it's a feature.  It is a solution in a user-friendly browser 
against script-kiddies.  So it is more likely to be implemented elsewhere 
than to go away.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18977

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-03-23 15:07 +0100
Message-ID<8005609.phbusdPiF5@PointedEars.de>
In reply to#18969
Cezary Tomczyk wrote:

> W dniu 2013-03-22 04:06, Scott Sauyet pisze:
> [...]
>>      (function() {
>>          var field = …;
>>          window.setTimeout(function () {
>>              field.focus();
>>          }, 50);
>>      }());
> 
> Does setTimeout for setting focus is still needed?

Wrong question.  Ask instead if setTimeout() still helps there.

> I remember when this was used for some old version of Firefox.

Newer versions of Firefox are likely to be more user-friendly than their 
predecessors.

> On the other hand I saw something like:
> 
> field.blur().focus();

Stupid is as stupid does.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18984

FromCezary Tomczyk <cezary.tomczyk@gmail.com>
Date2013-03-24 12:38 +0100
Message-ID<kimoka$hdd$1@speranza.aioe.org>
In reply to#18977
W dniu 2013-03-23 15:07, Thomas 'PointedEars' Lahn pisze:
> Cezary Tomczyk wrote:
[...]
>> Does setTimeout for setting focus is still needed?
>
> Wrong question.  Ask instead if setTimeout() still helps there.

Better, but I think that the question could even be more extended and 
contains some details about in what setTimeout helped in the past.

>> I remember when this was used for some old version of Firefox.
>
> Newer versions of Firefox are likely to be more user-friendly than their
> predecessors.

I think so too.

>> On the other hand I saw something like:
>>
>> field.blur().focus();
>
> Stupid is as stupid does.

Unfortunately, some solutions don't look nice, but they work.

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

[toc] | [prev] | [next] | [standalone]


#18985

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-03-24 13:42 +0100
Message-ID<1795729.QoGhUXEAOy@PointedEars.de>
In reply to#18984
Cezary Tomczyk wrote:

> W dniu 2013-03-23 15:07, Thomas 'PointedEars' Lahn pisze:
>> Cezary Tomczyk wrote:
>>> On the other hand I saw something like:
>>>
>>> field.blur().focus();
>>
>> Stupid is as stupid does.
> 
> Unfortunately, some solutions don't look nice, but they work.

For suitable values.  In this browser, the blur() method of form controls 
does not return a reference to its owner (but “undefined”), so the above 
throws a TypeError exception.  Either some idiot has attempted (and 
succeeded) to replace the blur() host method to work differently, they have 
not tested this sufficiently, or “field” refers to a user-defined wrapper 
object.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18986

FromCezary Tomczyk <cezary.tomczyk@gmail.com>
Date2013-03-24 13:54 +0100
Message-ID<kimt26$ttk$1@speranza.aioe.org>
In reply to#18985
W dniu 2013-03-24 13:42, Thomas 'PointedEars' Lahn pisze:
> Cezary Tomczyk wrote:
>
>> W dniu 2013-03-23 15:07, Thomas 'PointedEars' Lahn pisze:
>>> Cezary Tomczyk wrote:
>>>> On the other hand I saw something like:
>>>>
>>>> field.blur().focus();
>>>
>>> Stupid is as stupid does.
>>
>> Unfortunately, some solutions don't look nice, but they work.
>
> For suitable values.  In this browser, the blur() method of form controls
> does not return a reference to its owner (but “undefined”), so the above
> throws a TypeError exception.  Either some idiot has attempted (and
> succeeded) to replace the blur() host method to work differently, they have
> not tested this sufficiently, or “field” refers to a user-defined wrapper
> object.

I just remembered where I saw this field.blur().focus(); The "field" 
(the variable name was different, of course, but it doesn't matter in 
this example) was reference to jQuery object. That's why using 
blur().focus() worked without throwing exception. :-)

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web