Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #13203 > unrolled thread
| Started by | Gene Wirchenko <genew@ocis.net> |
|---|---|
| First post | 2012-04-03 16:57 -0700 |
| Last post | 2012-04-04 02:31 -0400 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.javascript
Clicking on Disabled Controls Gene Wirchenko <genew@ocis.net> - 2012-04-03 16:57 -0700
Re: Clicking on Disabled Controls Mike Duffy <Use_guestbook_page@website.in.sig> - 2012-04-04 00:59 +0000
Re: Clicking on Disabled Controls Gene Wirchenko <genew@ocis.net> - 2012-04-03 21:42 -0700
Re: Clicking on Disabled Controls BootNic <bootnic.bounce@gmail.com> - 2012-04-04 02:31 -0400
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-04-03 16:57 -0700 |
| Subject | Clicking on Disabled Controls |
| Message-ID | <8t2nn7tobq7196cv20msfns6hnh6mas0of@4ax.com> |
Dear JavaScripters:
Can someone please point me to a good reference as to what
happens when one clicks on a disabled control?
I have buttons on my form for adding, updating, deleting, etc.
Once one is clicked and DE is done, I disable most of them. Should
one of the disabled buttons get clicked, it does not get the focus,
but the control that does have focus at the time has its blur fire. (I
would simply like to put the focus back.)
In this case, document.activeElement has a value that I have not
been able to figure out. It is not null. It has an id of "". (This
happens even if the disabled control clicked on has an id.)
Clicking on other parts of my page can also cause similar
trouble. There is nothing to do there, but focus gets messed up.
What is going on, event-wise?
Sincerely,
Gene Wirchenko
[toc] | [next] | [standalone]
| From | Mike Duffy <Use_guestbook_page@website.in.sig> |
|---|---|
| Date | 2012-04-04 00:59 +0000 |
| Message-ID | <XnsA02AD5826113Binvalidcom@94.75.214.39> |
| In reply to | #13203 |
Gene Wirchenko <genew@ocis.net> wrote in news:8t2nn7tobq7196cv20msfns6hnh6mas0of@4ax.com: > ...please point me to a good reference as to what > happens when one clicks on a disabled control? > > .... Should one of the disabled buttons get clicked, > it does not get the focus, but the control that does > have focus at the time has its blur fire. > ... What is going on, event-wise? I'm not sure. Your message made me curious, and I found: http://help.dottoro.com/ljmiswgp.php Only one element can be active at a time in a document. An active element does not necessarily have focus, but an element with focus is always the active element in a document. For example, an active element within a window that is not the foreground window has no focus. To set the active element in a document, use the focus and setActive methods. To determine whether the active element has focus, use the hasFocus method. Also, at http://msdn.microsoft.com/en-us/library/aa752581%28v=vs.85% 29.aspx : You can set the active element with the setActive method or the focus method; however, using the setActive method has no effect on document focus. Use the focus method to cause an individual element to gain focus and become the active element. Note: For versions of Microsoft Internet Explorer 5 and later, the IHTMLDocument2::activeElement property is not defined until a document is loaded. A value of NULL is given for this property, if it is accessed inline during the loading of a document. This property can be accessed in the onload event handler function. I'm not sure if I'm telling you things you already know (because these are the first teo sites Google returns on a "activeElement" search), but both of these sites seem to have information related to your problem. It seems that being active does not mean the same thing as being in focus. -- http://pages.videotron.ca/duffym/index.htm
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-04-03 21:42 -0700 |
| Message-ID | <t5knn7tru4d9qdjc44jspoghnmqepi5cit@4ax.com> |
| In reply to | #13205 |
On Wed, 4 Apr 2012 00:59:15 +0000 (UTC), Mike Duffy
<Use_guestbook_page@website.in.sig> wrote:
[snip]
>I'm not sure if I'm telling you things you already know (because these
>are the first teo sites Google returns on a "activeElement" search), but
>both of these sites seem to have information related to your problem. It
>seems that being active does not mean the same thing as being in focus.
No, you are not. Thank you for the lead. I was wondering how I
was going to dig my way out. Now, I have a chance.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | BootNic <bootnic.bounce@gmail.com> |
|---|---|
| Date | 2012-04-04 02:31 -0400 |
| Message-ID | <20120404023145.177c2efd@bootnic.server> |
| In reply to | #13203 |
[Multipart message — attachments visible in raw view] — view raw
In article <8t2nn7tobq7196cv20msfns6hnh6mas0of@4ax.com>,
Gene Wirchenko <genew@ocis.net> wrote:
[snip]
> (I would simply like to put the focus back.)
<script type="text/javascript">
var last;
function checkDisabled(elm) {
var button = elm.querySelector('button');
if (last && button.disabled) {
last.focus();
}
last = null;
}
</script>
<style type="text/css">
[data-info] {
display: inline-block;
}
button[disabled] {
position: relative;
z-index: -1;
}
</style>
<div>
<input type="text" onblur="last=this;">
</div>
<div>
<span onclick="checkDisabled(this)" data-info="reset">
<button type="rest" disabled="disabled" onclick=
"alert('reset button clicked')">Reset</button>
</span>
</div>
<div>
<span onclick="checkDisabled(this)" data-info="submit">
<button type="submit" onclick=
"alert('submit button clicked')">Submit</button>
</span>
</div>
[snip]
--
BootNic Wed Apr 4, 2012 02:31 am
Man who scratch ass should not bite fingernails.
*Ancient Chinese Proverbs*
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web