<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>post-next -Ted Drake's sketchbook &#187; JavaScript</title>
	<atom:link href="http://www.tdrake.net/category/web-design/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tdrake.net</link>
	<description></description>
	<lastBuildDate>Fri, 12 Mar 2010 21:36:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Z-index conflict with Flash and DHTML widgets</title>
		<link>http://www.tdrake.net/z-index-conflict-with-flash-and-dhtml-widgets/</link>
		<comments>http://www.tdrake.net/z-index-conflict-with-flash-and-dhtml-widgets/#comments</comments>
		<pubDate>Tue, 21 Feb 2006 05:30:41 +0000</pubDate>
		<dc:creator>Ted Drake</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[XHMTL]]></category>
		<category><![CDATA[Yahoo!]]></category>

		<guid isPermaLink="false">http://www.tdrake.net/z-index-conflict-with-flash-and-dhtml-widgets/</guid>
		<description><![CDATA[I&#8217;m working on a project that has a Flash movie and a DHTML dropdown menu on the same page.  Flash movies like to sit on top of the page and the dropdown would slide behind the movie.  Since this isn&#8217;t what I wanted, I needed to find a way to make the it [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a project that has a <a href="http://www.macromedia.com">Flash</a> movie and a DHTML dropdown menu on the same page.  Flash movies like to sit on top of the page and the dropdown would slide behind the movie.  Since this isn&#8217;t what I wanted, I needed to find a way to make the it have a lower <a href="http://www.w3.org/TR/REC-CSS2/visuren.html">z-index</a> than the dropdown.</p>
<p>I did a <a href="http://www.tdrake.net/standards-based-web-development-resources-made-even-easier/">Standardista Search</a> for a cure and didn&#8217;t see it. But a quick message to the <a href="http://webstandardsgroup.org/">Web Standards Group</a> returned the solution. It&#8217;s actually pretty easy.</p>
<h3>UFO Flash detection and insertion script</h3>
<p>I&#8217;m using the <a title="Unobtrusive Flash Object" href="http://www.bobbyvandersluis.com/ufo/">UFO JavaScript</a> to detect the browser&#8217;s compatibility with the Flash movie and insert it on the fly. This method provides good default content to those without Flash and valid, shiny, happy Flash to those with it.</p>
<p>UFO gives you the ability to insert parameters into the movie and this is what you need to cure the z-index issue. You need to set the <strong>wmode</strong> parameter to &#8220;<em>transparent</em>.&#8221;</p>
<div class="codesnip-container" >var FO = { movie:&#8221;swf/myMovie.swf&#8221;, width:&#8221;300&#8243;, height:&#8221;120&#8243;,      majorversion:&#8221;6&#8243;, build:&#8221;40&#8243;, wmode:&#8221;transparent&#8221; }</div>
<p>That&#8217;s all there is to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tdrake.net/z-index-conflict-with-flash-and-dhtml-widgets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE7 Beta 2 is out for developers to test</title>
		<link>http://www.tdrake.net/ie7-beta-2-is-out-for-developers-to-test/</link>
		<comments>http://www.tdrake.net/ie7-beta-2-is-out-for-developers-to-test/#comments</comments>
		<pubDate>Wed, 01 Feb 2006 17:22:32 +0000</pubDate>
		<dc:creator>Ted Drake</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[XHMTL]]></category>

		<guid isPermaLink="false">http://www.tdrake.net/ie7-beta-2-is-out-for-developers-to-test/</guid>
		<description><![CDATA[IE7 Beta 2 is now available for developers to begin testing.  I&#8217;ve been suggesting on the web standards group mailing list that people need to begin looking beyond 2005 and start coding for IE7 and 2006.  That doesn&#8217;t mean you design for IE7 and hack for Firefox. No, it means you can begin [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.microsoft.com/windows/IE/ie7/devwebchecklist.mspx">IE7 Beta 2</a> is now available for developers to begin testing.  I&#8217;ve been suggesting on the web standards group mailing list that people need to begin looking beyond 2005 and start coding for IE7 and 2006.  That doesn&#8217;t mean you design for IE7 and hack for Firefox. No, it means you can begin using more sophisticated CSS rules. Here&#8217;s a very brief summary of what I&#8217;ve seen with IE7 Beta 2 so far.</p>
<h3>Rolling out IE7</h3>
<p>Microsoft has an aggressive agenda to upgrade people from IE6 to IE7. By the end of Fall, we should see a significant percentage of our web site visitors using IE7 and by the end of the year, the majority of our traffic will be IE7.  Those without IE7 are machines with illegal copies of XP, people with XP Service Pack 1, and those that don&#8217;t accept Microsoft service updates.</p>
<h3>Use real CSS</h3>
<p>If you are working on a site now, begin using real CSS.</p>
<ul>
<li>Use child selectors, first-child, <a href="http://www.tdrake.net/attribute-selectors-to-provide-language-information/">attribute selectors</a>, etc.</li>
<li>Hover your list items and more. IE7 supports the hover pseudoclass on more than the link.</li>
<li>IE7 offers full support of alpha transparent png graphics, so begin using them as well.</li>
</ul>
<p>Forget what you knew about &#8220;* html&#8221;, those hacks now belong in a style sheet that is introduced via a <a href="http://www.quirksmode.org/css/condcom.html">conditional comment</a>. <!-- The only hack you will need to know for IE7 is the *attribute hack  (*width:100px). All of the others -->They are <a href="http://blogs.msdn.com/ie/archive/2005/09/02/460115.aspx">gone, kaput, zilch</a>. Sure, they&#8217;ll still work on IE6, but you&#8217;re going to have one heck of a nightmare keeping track.</p>
<h3>Test Sites</h3>
<p>I am a big fan of <a href="http://www.stuffandnonsense.co.uk/">All that malarkey (Andy Clarke)</a>. However, his site is full of special rules for IE6 and its a great testing ground to see what IE7 chokes on and what it does as good as Firefox, Opera, and Safari. If your site is fairly hack free, you probably won&#8217;t notice a difference going from Firefox to IE7 Beta 2.  Start hunting around and finding the errors.</p>
<h3>What is still broken on IE7</h3>
<p>There are  two major issues that I have with IE7.</p>
<ol>
<li>No generated content. You can&#8217;t use CSS to add checkmarks to visited links, clearing containers spans, etc.</li>
<li>Double float margin still exists.  This can be fixed by adding display:inline to your floated objects when this problem occurs.</li>
<li>While I haven&#8217;t been able to nail down the specifics, there seems to be some bugginess with positioning absolute/relative.</li>
</ol>
<p>I&#8217;m sure there will be much better analysis of this launch by <a href="http://www.positioniseverything.net/">PositionIsEverything</a>, <a href="http://www.quirksmode.org/blog/index.html">Quirksmode</a>, and the <a href="http://blogs.msdn.com/ie/">IE7blog</a>. I hope these scribbled notes help you move forward.  IE7 is a good thing. It&#8217;s not perfect, but damn it sure is nice to ditch the <a title="a javascript that makes IE6 perform as if it understands the :hover pseudoclass" href="http://www.456bereastreet.com/archive/200405/son_of_suckerfish_dropdowns/">son of suckerfish javascript</a>, class=&#8221;firstitem&#8221;, haloed transparent gifs, et al.</p>
<p><ins>I forgot to mention, IE7 replaces IE6 on your computer. You need to have an extra computer to continue testing your pages in IE6. If you only have one windows box, I&#8217;d suggest keeping IE6 on that and just program for Firefox, et al and placing your IE6 hacks in a conditional comment linked style sheet</ins></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tdrake.net/ie7-beta-2-is-out-for-developers-to-test/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft IE7 updates the select box</title>
		<link>http://www.tdrake.net/microsoft-ie7-updates-the-select-box/</link>
		<comments>http://www.tdrake.net/microsoft-ie7-updates-the-select-box/#comments</comments>
		<pubDate>Wed, 18 Jan 2006 17:22:18 +0000</pubDate>
		<dc:creator>Ted Drake</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[XHMTL]]></category>

		<guid isPermaLink="false">http://www.tdrake.net/microsoft-ie7-updates-the-select-box/</guid>
		<description><![CDATA[Microsoft has just announced IE7 will handle the select input as a modern browser should. It will now allow developers to use z-index to avoid overlapping and perhaps more artistic forms. Søren Madsen put together the utopia of form design, something every designer should look at and dream of possibilities.

SELECT element in IE7 &#8211; An [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft has just announced IE7 will handle the select input as a modern browser should. It will now allow developers to use z-index to avoid overlapping and perhaps more artistic forms. Søren Madsen put together the <a href="http://www.picment.com/articles/css/funwithforms/">utopia of form design</a>, something every designer should look at and dream of possibilities.</p>
<blockquote cite="http://blogs.msdn.com/ie/archive/2006/01/17/514076.aspx">
<h4>SELECT element in IE7 &#8211; An Overview</h4>
<p>In IE6, the HTML SELECT element was implemented through the  Windows Shell ListBox and Combobox controls. Some key features were  missing in the old version of the SELECT element, such as proper  support for <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/zindex.asp">z-index</a>, <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/title_1.asp">TITLE</a> support, and <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/zoom.asp">zoom</a>. Web developers had to write complex CSS and scripts to workaround these issues.</p>
<p>In IE7 however, we re-implemented the SELECT element to make  IE7 more standards-compliant. This new version does not use any Shell  controls any more. In fact, it is implemented totally through the  MSHTML framework, including styling, UI interaction, and rendering.  Thus the SELECT element in IE7 is more of an HTML element than the  former legacy control.</p>
<p><cite><a href="http://blogs.msdn.com/ie/archive/2006/01/17/514076.aspx">IEBlog</a></cite></p></blockquote>
<h3>Form design is frustrating.</h3>
<p>Form elements are up to the browser for final presentation unless you get into some tricky CSS and JS solutions and those are not necessarily cross-browser solutions. One particular problem I&#8217;ve experienced was with the <a href="http://www.kryogenix.org/code/browser/nicetitle/">nicetitles</a> javascript that creates a nice popup box with the text of a title attribute on hover. I tried to use this on an insurance quote form to give the visitor better feedback on what was needed. IE6 would place the inputs on top of the popup window. I then tried moving the popup farther to the side to avoid this and that just looked hokey. So, I gave up on the idea. It would be interesting to test this now with IE7.</p>
<p>I&#8217;m also intrigued by the ability to use the title attribute on the select object. Normally, I would place the title on the label. However there may be times when the visual design requires hiding the label. Placing a title on the select would be a great way of letting people know the page may refresh or whatever action the select box leads to.</p>
<p>With rumors floating of an IE7 Beta2 developer release within a few weeks, we should begin looking for pages to test these new attributes on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tdrake.net/microsoft-ie7-updates-the-select-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Common JavaScript File</title>
		<link>http://www.tdrake.net/creating-a-common-javascript-file/</link>
		<comments>http://www.tdrake.net/creating-a-common-javascript-file/#comments</comments>
		<pubDate>Sat, 03 Dec 2005 01:02:53 +0000</pubDate>
		<dc:creator>Ted Drake</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[XHMTL]]></category>

		<guid isPermaLink="false">http://www.tdrake.net/?p=91</guid>
		<description><![CDATA[Dustin Diaz released his personal recipe for a common JavaScript file. You know the file that includes the basic functions that any web site can use. We&#8217;ve all grabbed some of these scripts from here and there and its nice to see it one-stop shopping packaging. 
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dustindiaz.com/" rel="coworker">Dustin Diaz</a> released his personal recipe for a <a href="http://www.dustindiaz.com/top-ten-javascript/">common JavaScript file</a>. You know the file that includes the basic functions that any web site can use. We&#8217;ve all grabbed some of these <a href="http://adactio.com/" title="Jeremy Keith's Website">scripts</a> from <a href="http://www.quirksmode.org" title="The all mighty PPK web site - Quirksmode">here</a> and <a href="http://simon.incutio.com/" title="Visit Simon Willison's Weblog">there</a> and its nice to see it one-stop shopping packaging. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.tdrake.net/creating-a-common-javascript-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Should a web site open pdf files in a new window?</title>
		<link>http://www.tdrake.net/should-a-web-site-open-pdf-files-in-a-new-window/</link>
		<comments>http://www.tdrake.net/should-a-web-site-open-pdf-files-in-a-new-window/#comments</comments>
		<pubDate>Mon, 29 Aug 2005 03:39:39 +0000</pubDate>
		<dc:creator>Ted Drake</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[XHMTL]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[Web browser]]></category>

		<guid isPermaLink="false">http://www.tdrake.net/?p=69</guid>
		<description><![CDATA[Web designers need to choose between offering convenience to unsophisticated web visitors and hijacking the browser from those who want to control how their browsers open non-HTML files]]></description>
			<content:encoded><![CDATA[<p>A few years ago, I was visiting some friends in Paris. One is a fairly conservative priest and the other a socialist teacher.<br />
I asked them a seemingly innocent question: What&#8217;s the deal with Robespierre? Why do people feel so strongly one way or another about him?</p>
<p>I had just begun learning about <a href="http://en.wikipedia.org/wiki/French_Revolution" title="French Revolution" rel="wikipedia" class="zem_slink">the French Revolution</a> and was not prepared for the argument that arose. Robespierre and the<br />
Reign of Terror still divide people into camps.</p>
<p><iframe src="http://rcm.amazon.com/e/cm?t=csstoyslastch-20&amp;o=1&amp;p=8&amp;l=as1&amp;asins=1590596382&amp;md=10FE9736YVPPT7A0FBG2&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr" style="margin: 5px; width: 120px; height: 240px; float: right;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0"></iframe><br />
It&#8217;s rare to find a topic with such strong opinions expressed in web design (not counting <a href="http://www.microsoft.com/windows/products/winfamily/ie/default.mspx" title="Internet Explorer" rel="homepage" class="zem_slink">Internet Explorer</a>). However, I recently found the<br />
standardista populace building ramparts in the streets of the city when I asked the seemingly innocent question: &#8220;<strong>Should .pdf files be opened in a new window?</strong>&#8221;</p>
<h3>The answers fall into two main camps:</h3>
<ol>
<li>Do not hijack the browser; let the user determine the behavior of their browser.</li>
<li>Make it easier for visitors that are not savvy enough to know how to control their browser&#8217;s options.</li>
</ol>
<h3>Hypothetical vs. Reality</h3>
<p>In a perfect world, information is provided efficiently in all browsers to people of all abilities. <abbr title="HyperText Markup Language" lang="en">HTML</abbr> code should not interfere with the<br />
browser&#8217;s native behavior, allowing the user to establish preferences for font size, background-color, and file downloading.</p>
<p>In the real world, the visitor has to wait for files to be presented, can lose track of the original web page, and can accidentally shut down<br />
the browser instead of the file. Therefore, the programmer can assist the viewer by opening the file in a new window.</p>
<p>I&#8217;ve summarized the recent comments over this question (from the web standards group mailing list) to decide which is the best approach.</p>
<h3>Basic standards</h3>
<p>Regardless of the window option you choose, there are some elements that everyone agrees upon. The link must let the visitor know that<br />
they are opening something other than another web page. The file type and file size should be attached to the link, i.e.:
<div class="codesnip-container" >&lt;a xhref=””&gt;contact list (.pdf, 25kb)&lt;/a&gt;</div>
<p>. This gives the visitor the basic information needed to make an informed decision about how the file should be opened.</p>
<p>The developer could also give the link more information to assist the visitor: </p>
<div class="codesnip-container" >&lt;a xhref=”contact.pdf” title=”This link will open a .pdf file. Acrobat Reader is required”&gt;contact list (.pdf, 25kb)&lt;/a&gt;</div>
<p>. If the visitor does not have the required plug-in, they should be given<br />
a link to the appropriate download site.
<div class="codesnip-container" >&lt;a xhref=”contact.pdf” title=”This link will open a .pdf file to be read in Acrobat Reader”&gt;contact list&lt;/a&gt; (&lt;a xhref= <a href="http://www.adobe.com/">http://www.adobe.com </a> title=”Download the plugin required to view a Portable Document Format file”&gt;.pdf&lt;/a&gt;, 25kb)</div>
<p> .<br />
<a href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets" title="Cascading Style Sheets" rel="wikipedia" class="zem_slink">CSS</a> can also be used to place the Acrobat icon next to the link:</p>
<h3>Version 1:</h3>
<dl>
<dt>HTML: </dt>
<dd>
<div class="codesnip-container" >&lt;a xhref=”contact.pdf” class=&#8221;pdfFile&#8221; title=”This link will open a .pdf file.”&gt;contact list (.pdf, 25kb)&lt;/a&gt;</div>
</dd>
<dt>CSS: </dt>
<dd>
<div class="codesnip-container" >.pdfFile {background: url(pdflogo.gif) no-repeat 0 0; padding-left:25px;}</div>
</dd>
</dl>
<h3>Version 2:</h3>
<p>Use JavaScript to find links with .pdf in the href and insert the class=”.pdfFile” dynamically</p>
<h3>Version 3:</h3>
<p>Use CSS3 syntax to add the icon to all links with .pdf in the href. Most browsers do not support this.</p>
<p>Let the visitor know that the link is to something other than another web page. The easiest method is to follow the link with the file name<br />
and size; all other additions are usability gravy.</p>
<h2>Do not open new windows</h2>
<p>Pop-up windows are bad for accessibility and usability. The WAI answers the pop-up question quite plainly:</p>
<blockquote cite="http://www.w3.org/WAI/wcag-curric/sam77-0.htm">
<h3>WAI Checkpoint 10.1</h3>
<p>Until user agents allow users to turn off spawned windows, do not cause pop-ups or other windows to appear and do not change the current window without informing the user.</p>
<p><cite><a href="http://www.w3.org/WAI/wcag-curric/sam77-0.htm">http://www.w3.org/WAI/wcag-curric/sam77-0.htm</a> </cite></p></blockquote>
<p>However, the first part of this rule has been satisfied. Modern web browsers now block unwanted popup windows. This rule seeks to prevent web sites from launching new windows when a visitor comes to the site. The second part of the rule requires the visitor to be warned that such behavior may happen. This requirement does not banish new windows altogether, rather those that the visitor has no control over.</p>
<p>Many people believe that the visitor should have control over their browser or other rendering device at all times. The savvy user will know how they prefer to see a file and the web site should not pre-determine this action.</p>
<blockquote><p>I would say let the user decide. Wherever possible I try to provide enough information in the link itself so that the user knows what to<br />
expect and can proceed as they wish. Many people will set up their browser to deal with different file types according to their preference<br />
(open the document in the browser, open it in the application, download the file). Opening in a new window removes user choice. By providing a<br />
plain link you give users the option … of `right-click &#8211; open in new window`.</p>
<p><cite>- Damian <a href="http://airport.unimelb.edu.au">airport.unimelb.edu.au</a></cite></p></blockquote>
<p>Users with assistive technology or portable devices also have difficulties with multiple windows.</p>
<blockquote><p>Accessibility considerations would be ensuring that users are advised of what will happen when they activate the link, either that the<br />
document would be opened in a new window, or that it will be downloaded. Also that opening a new window does not adversely effect users<br />
accessing a website with assistive technologies (screen readers, etc.).</p>
<p><cite>- Andy Kirkwood | Creative Director   <a href="http://www.motive.co.nz/">http://www.motive.co.nz </a></cite></p></blockquote>
<p>These issues need to be addressed if the web site chooses to open these links in a new window.</p>
<h2>The argument for opening new windows</h2>
<p>The Internet is not full of expert users. That is the simple reality. An effective web site compensates for visitor behavior and creates a seamless experience. While this is not always possible, the programmer can minimize frustrations. Opening a document in the original window creates its own set of problems for the user. Even the savvy visitor will sometimes forget to right-click on a link and choose “open in a new window” or “save target as.”</p>
<p>Many of our users are very computer illiterate and giving them too many options confuses them. We do open our PDF documents in a new window and never have any complaints about it.</p>
<blockquote><p>We DO get complaints, though, when things are too hard to use or if the page they were on &#8220;disappears&#8221; because we opened a &#8220;document&#8221; in that same window or if the file downloaded and they can&#8217;t find it (happened regularly before we launched the PDF in another window).</p>
<p><cite>Gary Menzel,  Senior Software Engineer, <a href="http://www.medeserv.com.au/">Med-E-Serv Pty Ltd</a></cite></p></blockquote>
<p>Many users have become accustomed to having windows appear to log-in, handling web applications, for advertisements, help sections, and more. Further, they are used to closing the windows by clicking on the browser&#8217;s close button. When the pdf document loads in the original window, the visitors will often close the browser, expecting the original web site to appear. Instead, they have closed the web browser and will have to navigate their way back to the original page. For many, this may involve doing another search if they are not comfortable using the history feature.</p>
<blockquote><p>&#8230; I&#8217;ve had users report that they close the window thinking that they&#8217;re exiting the document, but they&#8217;re actually closing the browser.</p>
<p><cite>Mario, <a href="http://www.webnetdesignstudios.com/">www.webnetdesignstudios.com </a></cite></p></blockquote>
<p>Opening the documents in a new window can create a friendlier environment for the user. It preserves the original page and allows the visitor to continue reading the web site while the new file is being prepared in another window. However, it needs to be done in a manner that does not violate accessibility requirements.</p>
<h3>JavaScript to the rescue</h3>
<p>In the past, links were given a target to choose which window a link was opened in. This was meant for web sites using frames. Open the<br />
link in the top, side, body, footer, etc. A new window could also be generated if the page was not using frames or if the targeted id did<br />
not exist in the frameset. Target=”_blank” became the standard code for opening a new window:
<div class="codesnip-container" >&lt;a xhref=”contact.pdf” target=”blank”&gt;</div>
<p>.<br />
However, this assumes the visitor is able to keep visual track of the windows. It also does not account for browsing devices that do not<br />
recognize multiple windows.</p>
<p>There are two methods for using JavaScript to make a link open a new window.</p>
<h3>Insert the script into the link code</h3>
<dl>
<dt>HTML </dt>
<dd>
<div class="codesnip-container" >&lt;a xhref=”contact.pdf” onclick=&#8221;window.open(this.href); return false;&#8221; title=”This link will open a pdf file in a new window” class=”pdfFile”&gt;contact list (.pdf, 25kb)&lt;/a&gt;</div>
</dd>
</dl>
<p>This script tells the browser to open a window with the url listed in the href. If the browser does not recognize the window.open command,<br />
ignore the function and open the link in the original window.</p>
<h3>Removing the script from the link</h3>
<p>Thierry Koblentz of <a href="http://www.TJKDesign.com">TJK Design</a> developed the following JavaScript for this article.  The script searches for  any file downloaded as application/pdf, that sits in a folder named &#8220;pdf&#8221;, or has the extension of .pdf. It then adds class=&#8221;pdfFile&#8221; for the CSS, a title attribute to notify the visitor that the link will open a new window, and gives the programmer the option of using target=&#8221;_blank&#8221; or window.open to create the new window.</p>
<dl>
<dt>HTML </dt>
<dd>
<div class="codesnip-container" >&lt;a xhref=”contact.pdf”&gt;contact list (.pdf, 25kb)&lt;/a&gt;</div>
</dd>
<dt>JavaScript (http://www.tjkdesign.com/articles/popups.asp) </dt>
<dd>
<div class="codesnip-container" ></div>
<ol>
<li>function TJKpopAppPdf(){ // v1.0 | <a href="http://www.TJKDesign.com">www.TJKDesign.com </a></li>
<li>var zA=document.getElementsByTagName(&#8217;a');</li>
<li>for (var i=0;i&lt;zA.length;i++){</li>
<li>// This is if the href value contains the string &#8220;.pdf&#8221; or if the anchor contains the correct &#8220;type&#8221; attribute or if the file is stored in a PDF folder</li>
<li>if (zA[i].getAttribute(&#8217;href&#8217;) != null &amp;&amp;</li>
<li>(zA[i].getAttribute(&#8221;type&#8221;)== &#8220;application/pdf&#8221; ||</li>
<li>zA[i].getAttribute(&#8217;href&#8217;) .toUpperCase().indexOf(&#8221;.PDF&#8221;) &gt;= 0 ||</li>
<li>zA[i].getAttribute(&#8217;href&#8217;) .toUpperCase().indexOf(&#8221;PDF/&#8221;) &gt;= 0)){</li>
<li>// This is to include a title attribute or attach a string to an existing title&#8217;s value</li>
<li>zA[i].title+=&#8217; (opens in new window)&#8217;;</li>
<li>// This is to include a class or attach one to an existing class&#8217; value</li>
<li>zA[i].className+=zA[i].classNam e?&#8217; pdfFile&#8217;:'pdfFile&#8217;;</li>
<li>// This spawns multiple windows, but works fine with popup blockers</li>
<li>// zA[i].target=&#8217;_blank&#8217;;</li>
<li>// This opens a unique window and brings it in front of the opener each time the user clicks on the link</li>
<li>zA[i].onclick=function() {newWin=window.open(this.href,&#8217;TJKWin&#8217;,'toolbar=no&#8217;);</li>
<li>if( window.focus){newWin.focus()} return false;}</li>
<li>}</li>
<li>}</li>
<li>}</li>
<li>window.onload=function(){if(document.getElementById) TJKpopAppPdf()};</li>
</ol>
</dd>
</dl>
<p>The name TJKWin is given to the new window to assure that all pdf links open in the same window. This keeps the visitor from ending up with a plethora of new windows for each pdf they open.  If the browsing device is not capable of opening new windows, it will ignore the script and simply open the link in the existing window.</p>
<p>If you expect your audience to compare multiple files, you may want to remove the window name designation from the script.</p>
<blockquote><p>Opening all documents in a window with the same name is obviously &#8216;tidy&#8217;, but problematic if a user wants to open and compare the contents of two documents simultaneously.</p>
<p><cite>Andy Kirkwood</cite></p></blockquote>
<h2>Other file types</h2>
<p>This still leaves the discussion open for other file types. Should a new window be opened for spreadsheets, PowerPoint presentations, Visio documents, XML files, and more? Some of these files can be viewed in the browser, but they would be better left as a downloaded document to be viewed natively. The visitor still needs to be notified the link is for a non-HTML link:</p>
<dl>
<dt>HTML: </dt>
<dd>
<div class="codesnip-container" >&lt;a xhref=”contaxt.xls” class=”exceldownload” title=”This link will download an excel file”&gt;contact.xls (.xls, 25kb)&lt;/a&gt;</div>
</dd>
</dl>
<p>The previous javascript could also be modified to give .xls files the appropriate class and title, making the code even cleaner.</p>
<h2>Summary</h2>
<p>Web site visitors expect to find information in an efficient, user-friendly manner. It is up to the web designer to create this experience. While opening new windows may be considered a faux pas, the average user will actually appreciate its convenience. JavaScript offers the most convenient method of giving a visual reference and functionality. Placing a helpful title attribute within the link further informs the visitor about the link&#8217;s behavior.</p>
<p><strong>Update</strong> To further avoid confusion for the visitor, Thierry changed the code slightly today. He added
<div class="codesnip-container" >,&#8217;toolbar=no&#8217;</div>
<p>to remove the browser&#8217;s toolbar:
<div class="codesnip-container" >(window.open(this.href,&#8217;TJKWin&#8217;,'toolbar=no&#8217;);)</div>
<p>. This approach was suggested by Jacob Nielsen&#8217;s Alertbox <a href="http://www.useit.com/alertbox/open_new_windows.html">Open New Windows for PDF and other Non-Web Documents</a>.</p>
<h3>Resources</h3>
<ul>
<li><a href="http://www.motive.co.nz/glossary/popup.php">Motive Glossary: Pop-up Windows</a></li>
<li><a href="http://www.w3.org/WAI/wcag-curric/sam77-0.htm">WAI Accessibility Requirements</a></li>
<li><a href="http://www.alistapart.com/articles/pdf_accessibility">Facts and Opinions About PDF Accessibility</a></li>
<li><a href="http://www.alistapart.com/articles/popuplinks">Accessible Pop-up Links</a></li>
<li><a href="http://www.accessify.com/tutorials/standards-compliant-new-windows.asp">Standards-Compliant New Windows &#8211; Extending XHTML</a></li>
</ul>
<div style="margin-top: 10px; height: 15px;" class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/b3dcf3a3-5ea0-4f75-b0f9-41e54ec1dca4/" title="Zemified by Zemanta"><img style="border: medium none ; float: right;" class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=b3dcf3a3-5ea0-4f75-b0f9-41e54ec1dca4" alt="Reblog this post [with Zemanta]"/></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tdrake.net/should-a-web-site-open-pdf-files-in-a-new-window/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
