W3C home > Mailing lists > Public > w3c-wai-gl@w3.org > October to December 2003

HTML techniques - Anchors and targets (possible blocker)

From: Yvette P. Hoitink <y.p.hoitink@heritas.nl>
Date: Fri, 31 Oct 2003 16:49:44 +0100
To: <w3c-wai-gl@w3.org>
Message-Id: <E1AFbWy-0004rT-HO@smtp5.home.nl>

In the HTML techniques document, there is a section about not opening
windows without informing the user:
<http://www.w3.org/WAI/GL/WCAG20/WD-WCAG20-HTML-TECHS-20031020.html#links_po
pup>

However, the example uses the target-attribute, which is not allowed anymore
in HTML 4.0 strict and XHTML 1.0 strict. This will be confusing for people
using strict HTML, since this example leads to invalid HTML then.

I think there should be at least one example of how to open a document and
warn about that when using strict instead of transitional HTML. The only way
(at least, to my knowledge) to automatically open new windows when using
strict HTML is by using Javascript. However, you want to avoid giving
warnings about opening new windows if people have Javascript disabled. 

Whenever I wish to open a hyperlink in a new window, I use the following
construction:

<a href="http://www.w3.org"
onclick="window.open(this.href,'external','toolbar=yes,location=yes,status=y
es,menubar=yes,scrollbars=yes,resizable=yes'); return false" 
onkeypress="this.onclick();">World Wide Web Consortium</a>
<script type="text/javascript">
<!-- 
document.write("(opens new window)") 
//-->
</script>

Explanation:
The href-attribute of the A is the only location that has the actual link,
so automatic link checkers still work. If Javascript is enabled, then
clicking the link will invoke the onclick method, which will open the link
in a new window. To assure that this functionality is available for keyboard
users as well, the onkeypress event calls the onclick event (this avoids
duplication of code). After the link, Javascript is used to print the
warning about the new window, so only when the link is opened in a new
Window (i.e. when Javascript is enabled), the warning is given.

Yvette Hoitink
CEO Heritas, Enschede, The Netherlands
Received on Friday, 31 October 2003 10:52:43 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:47:26 GMT