From: AKS on
On Dec 22, 11:59 am, Randy Webb <HikksNotAtH...(a)aol.com> wrote:

> It won't? The error message I posted was a direct copy/paste from Firefox.

I wrote about an error which IE throws when you try to call focus() on
hidden element.

> Why though? Just use focus...

> IE will setActive() on a hidden input (type="hidden"). It will throw an
> error if you try to set focus() to it.

I know (see my very first post).



From: Randy Webb on
AKS said the following on 12/22/2007 2:17 AM:
> On Dec 22, 11:59 am, Randy Webb <HikksNotAtH...(a)aol.com> wrote:
>
>> It won't? The error message I posted was a direct copy/paste from Firefox.
>
> I wrote about an error which IE throws when you try to call focus() on
> hidden element.

The simplest solution to that is in my reply to Thomas. Test the .type
property and if it is not type="hidden" then set focus.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
From: AKS on
On Dec 22, 12:35 pm, Randy Webb <HikksNotAtH...(a)aol.com> wrote:

> The simplest solution to that is in my reply to Thomas. Test the .type
> property and if it is not type="hidden" then set focus.

You haven't looked at my first post.
OK! Let's try your "simplest solution: test the .type property and if
it is not type="hidden" then set focus":

<script type='text/javascript'>

function F() {
var o = document.getElementById('search');
if (o && o.type != 'hidden') {
o.focus();
};
};

</script>

<body onload='F()'>

<input type='text' id='search' style='visibility:hidden'>

</body>

What will happen in IE?




From: Randy Webb on
AKS said the following on 12/22/2007 2:49 AM:
> On Dec 22, 12:35 pm, Randy Webb <HikksNotAtH...(a)aol.com> wrote:
>
>> The simplest solution to that is in my reply to Thomas. Test the .type
>> property and if it is not type="hidden" then set focus.
>
> You haven't looked at my first post.

I did look at it. And that is why I also, in my first reply to you, said
it should check *both*.

> <input type='text' id='search' style='visibility:hidden'>

Just for kicks and giggles:

<input type="text" id="search" style="display:none">

And, since you made such a fuss about testing the visibility property
itself:

<div style="visibility:hidden">
<input type="text" id="search">
</div>

Personally, I think the entire discussion is nothing more than a mental
exercise. The simplest solution is the one Bart gave. If it throws an
error then the programmer needs to know it *then*, not let it be hidden
in a function somewhere.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
From: AKS on
On Dec 22, 1:08 pm, Randy Webb <HikksNotAtH...(a)aol.com> wrote:

> Personally, I think the entire discussion is nothing more than a mental
> exercise. The simplest solution is the one Bart gave. If it throws an
> error then the programmer needs to know it *then*, not let it be hidden
> in a function somewhere.

Something, like this, can be more reliable (with hope that there are
no users of IE 5.0 and earlier):

function F() {
var o = document.getElementById('search');
if (o) {
if (o.setActive) {
o.setActive();
} else if (o.focus) {
o.focus();
};
};
};

But may be I'll choose select() method instead of two setActive/focus
(I wrote *may be*)...
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: print(), iframe, IE 5/6
Next: Request.Form in Javascript