[thelist] Window targeting problem

Jeff jeff at members.evolt.org
Mon, 17 Jan 2000 16:37:04 -0800


james,

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Aylard James J <jaylard@equilon.com>
:
: A couple of points of clarification: the focus() method is
: Javascript 1.1 (IE4 DOM in the IE world), so it doesn't work in Nav2 or
IE3
: (it'll throw an error). Of course, you can enclose "self.focus()" in a
: script block with a language attribute of "javascript 1.1". I think that
: Jeff also described another technique a month or so ago.(??)
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and i can gladly respond with that here again.

just check for the existence of the focus() method before using it.

from within the window you want to focus:

if(self.focus) self.focus()

from another window with a variable, assumed to be "newWin", that references
the window:

if(newWin.focus) newWin.focus();

personally i would avoid using a language defined method of preventing
errors.  if you call a function that's defined in a js1.1 <script> block, a
pre-js1.1 browser will throw an error because the function isn't visible to
it.  it's far better to check for method or object support and act
accordingly.

just a quick note on the focus() method.  support for focusing the window
(and frames since they're considered a window object) was introduced in
js1.1.  however, this has nothing to do with the focus() method for form
elements which was part of the original js1.0 spec.

good luck,

: jeff.howden
: web.development.professional
: evolt.org.member
:
: the.best.looking.developers.on.the.net
:
: http://evolt.org/
: jeff@members.evolt.org