[WEB4LIB] Re: FW: window.open
Thomas Dowling
tdowling at ohiolink.edu
Wed Sep 15 08:27:49 EDT 1999
Let me suggest that '<a href="javascript:...">' is not the solution. It
completely fails if Javascript is turned off, while other techniques will
maintain core functionality (a.k.a "the user can still follow the link").
This is a Priority 1 checkpoint in the W3C's web content accessibility
guidelines, by the way.
X% of your users turn off Javascript in their browsers for reasons of
preference or disability; if you don't know what value X has, and if you
can't guarantee that it's lower than some allowable minimum, you're
obligated to avoid this solution. Web crawlers may also be unable to
follow javascript links; if you use this for internal links, you might
make almost all of your web site invisible to Alta Vista et al.
If you simply want to indicate that the link should open in a new window,
'<a href="somewhere" target="_new">' is a simple option. If you feel
compelled to exert control over that window's size, presence or absence of
toolbars, keyboard focus, etc., you can add a script in the onClick
attribute:
<a href="somewhere"
target="OurExternalWindow"
onClick='extWin = window.open("", "OurExternalWindow",
"menubar=yes,scrollbar=yes,resizable=yes,width=400,height=350");
extWin.focus()'>
(Obviously, if you're doing this for multiple links, it's more efficient
to write a single <SCRIPT> element and just reference it by name in the
onClick attribute.)
As a final caution, opening new windows, in and of itself, is an
accessibility concern. (But allowing links to open new windows can be
disabled in Truly Enlightened Browsers, so it's not as critical as relying
exclusively on Javascript to make the link.)
See
<URL:http://www.w3.org/TR/WAI-WEBCONTENT/#gl-new-technologies>
<URL:http://www.w3.org/TR/WAI-WEBCONTENT-TECHS/#scripts-gt>
Thomas Dowling
OhioLINK - Ohio Library and Information Network
tdowling at ohiolink.edu
> I've found The JavaScript Source: Navigation Scripts
> <http://javascript.internet.com/navigation/> to be helpful. The script
> titled "New Window" seems to do what you need.
>
> - Donna
>
> Donna Stevenson, Web Services Librarian Email: stevenson.20 at nd.edu
> University Libraries of Notre Dame Phone: (219) 631-3543
> G131 Hesburgh Library, Notre Dame, IN http://www.nd.edu/~dstevens
>
> On Tue, 14 Sep 1999, Vickie L. Kline wrote:
>
> >
> > Pardon a question from a JavaScript newbie, but how would you set up
the
> > code if you had a list of different links to open as separate pages?
ie.
> > you wanted the user to be able to open either a link to Yahoo or to
Snap
> > as separate pages...
> >
> > TIA!
> >
> >
More information about the Web4lib
mailing list