<?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>Stamatis Kritikos &#187; Heavy Metal Labs</title>
	<atom:link href="http://stamatiskritikos.com/topic/heavy-metal-labs/feed/" rel="self" type="application/rss+xml" />
	<link>http://stamatiskritikos.com</link>
	<description>the web design specialist</description>
	<lastBuildDate>Thu, 17 Nov 2011 14:01:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Force download files and not open in browser</title>
		<link>http://stamatiskritikos.com/2011/07/25/force-download-files-and-not-open-in-browser/</link>
		<comments>http://stamatiskritikos.com/2011/07/25/force-download-files-and-not-open-in-browser/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 17:10:33 +0000</pubDate>
		<dc:creator>Stam</dc:creator>
				<category><![CDATA[Heavy Metal Labs]]></category>

		<guid isPermaLink="false">http://stamatiskritikos.com/?p=13</guid>
		<description><![CDATA[Are you tired of asking your users to right-click and "save link/target as" in order to download your .pdf (or game generated) files? Find out how to force download those files in any modern browser. ]]></description>
			<content:encoded><![CDATA[<p>Are you tired of asking your users to right-click and &#8220;save link/target as&#8221; in order to download your .pdf (or game generated) files? Find out how to force download those files in any modern browser. <span id="more-13"></span></p>
<p>There are situations where you might want a hyperlink leading to a file to trigger a &#8220;Save As&#8221; dialog in browser instead of having the browser trying to read/open that file.</p>
<p>This usually reigns true for PDF downloads or just obscure file types, such as files generated from various computer games.</p>
<p>For my case, I had some game generated file types I wanted to force download on them because a lot of users were reporting trouble getting the files as their browser was trying to read the files. I had to keep asking them to right-click on the download link and &#8220;save target/link as&#8221; for that to work properly.</p>
<h3>The Apache Solution</h3>
<p>So today I just got tired of advising for right-clicking and did a quick research how to force download those files on single left click for any modern browser. My sites are all using Apache, so the solution is cropping up to adding one line in the .htaccess file.</p>
<p>Here&#8217;s the code you need to add in your .htaccess:</p>
<p><code>AddType application/octet-stream .pdf</code></p>
<p>Replace .pdf with the file type in question. If you want to add multiple file types to this rule, you can either add a new line of the same and change the file extension or there&#8217;s a shortcut:</p>
<p><code>AddType application/octet-stream .pdf .doc .etc</code></p>
<p><small>Source: <a href="http://css-tricks.com/snippets/htaccess/force-files-to-download-not-open-in-browser/">CSS-Tricks</a></small></p>
<h3>The PHP Solution</h3>
<p>You could have a PHP wrapper for download links that takes an argument and then reads the file (assuming local files) and before outputting the file to the user you send headers with the file type. </p>
<p>Example: </p>
<p><code><?php<br />
// We'll be outputting a PDF<br />
header('Content-type: application/pdf');</p>
<p>// It will be called downloaded.pdf<br />
header('Content-Disposition: attachment; filename="downloaded.pdf"');</p>
<p>// The PDF source is in original.pdf<br />
readfile('original.pdf');<br />
?><br />
</code></p>
<p><small>Source: <a href="http://php.net/manual/en/function.header.php">PHP.net</a></small></p>
<h3>The HTTP Header Solution</h3>
<p>You have to include the following header in HTTP response of the file to be downloaded:</p>
<p><code>Content-Disposition: attachment; filename=filename.ext</code></p>
<p>Where filename.ext is the filename you want to appear in &#8220;Save As&#8221; dialog (eg. mycv.pdf). </p>
<p>You have to keep the following in mind:</p>
<ul>
<li>The filename should be in US-ASCII charset.</li>
<li>The filename should not have any directory path information specified.</li>
<li>The filename should not be enclosed in double quotes even though most browsers will support it.</li>
<li>Content-Type header should be before Content-Disposition.</li>
<li>Content-Type header should refer to an unknown MIME type (at least until the older browsers go away).</li>
</ul>
<p><small>Source: <a href="http://www.jtricks.com/bits/content_disposition.html">JTricks</a></small></p>
<h3>Choose what&#8217;s best for you</h3>
<p>Alright, I&#8217;ve presented you with the different ways you can achieve forcing download of files from links leading to them. If there&#8217;s a way I&#8217;ve missed please comment and I&#8217;ll update the post. </p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://stamatiskritikos.com/2011/07/25/force-download-files-and-not-open-in-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove Dotted Outline VS Accessibility</title>
		<link>http://stamatiskritikos.com/2010/01/03/remove-dotted-outline-vs-accessibility/</link>
		<comments>http://stamatiskritikos.com/2010/01/03/remove-dotted-outline-vs-accessibility/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 14:38:57 +0000</pubDate>
		<dc:creator>Stam</dc:creator>
				<category><![CDATA[Heavy Metal Labs]]></category>

		<guid isPermaLink="false">http://stamatiskritikos.com/?p=6</guid>
		<description><![CDATA[Remove the annoying dotted outline on links and form elements, keeping accessibility (and usability) intact... styling it too!]]></description>
			<content:encoded><![CDATA[<p>Remove the annoying dotted outline on links and form elements, keeping accessibility (and usability) intact&#8230; styling it too!<span id="more-6"></span></p>
<h3>The issue of dotted outline</h3>
<p>Webmasters (specifically semantic coders) usually get annoyed by the dotted outline that appears while clicking on a link (text or image) or a form element (button or other input fields such as radio). This can get ugly on the header part of a design, especially with coding that involves text indent.<br />
<em>You can try it for yourself by clicking on a link and mousing off of that link before letting go. This is done for accessibility (and usability), because when you are navigating with the keyboard, those outlines show you where your cursor is!</em></p>
<p>There is a series of solutions for this issue, but we should carefully decide what&#8217;s best as an overall value for price, as some solutions can hurt our site&#8217;s accessibility. Some of you might just don&#8217;t care, but I do.</p>
<p>So, let&#8217;s see what W3C says about outlines to help us get a backstage understanding, before we list the possible solutions.</p>
<h3>W3C introduction to the outline property</h3>
<p>By default browsers create outlines around visual objects such as links, buttons, active form fields.</p>
<p>Outlines behave similar to borders, but they differ from borders in the following ways:</p>
<ol>
<li>Outlines do not take up space.</li>
<li>Outlines may be non-rectangular.</li>
</ol>
<p>Let&#8217;s explain that.</p>
<p>1. The outline created with the outline properties is drawn &#8220;over&#8221; a box, i.e., the outline is always on top, and does not influence the position or size of the box, or of any other boxes. Therefore, displaying or suppressing outlines does not cause reflow or overflow.</p>
<p>2. Outlines may be non-rectangular. For example, if the element is broken across several lines, the outline is the minimum outline that encloses all the element&#8217;s boxes. In contrast to borders, the outline is not open at the line box&#8217;s end or start, but is always fully connected if possible.</p>
<h4>Which are the outline properties and how do they behave?</h4>
<p>The &#8216;<em>outline-width</em>&#8216; property accepts the same values as &#8216;<em>border-width</em>&#8216;.</p>
<p>The &#8216;<em>outline-style</em>&#8216; property accepts the same values as &#8216;<em>border-style</em>&#8216;, except that &#8216;hidden&#8217; is not a legal outline style.</p>
<p>The &#8216;<em>outline-color</em>&#8216; accepts all colors, as well as the keyword &#8216;<em>invert</em>&#8216;. &#8216;Invert&#8217; is expected to perform a color inversion on the pixels on the screen. This is a common trick to ensure the focus border is visible, regardless of color background.</p>
<p><small>If the browser does not support the &#8216;invert&#8217; value, then the initial value of the &#8216;outline-color&#8217; property is the value of the &#8216;color&#8217; property, similar to the initial value of the &#8216;border-top-color&#8217; property.</small></p>
<p>The &#8216;outline&#8217; property is a shorthand property, and sets all three of &#8216;outline-style&#8217;, &#8216;outline-width&#8217;, and &#8216;outline-color&#8217;.</p>
<p><em>The outline is the same on all sides, so no outline-top or outline-left. And since the outline does not affect formatting, it may well overlap other elements on the page. </em></p>
<h4>Outlines and focus</h4>
<p>Graphical user interfaces may use outlines around elements to tell the user which element on the page has the focus. These outlines are in addition to any borders, and switching outlines on and off should not cause the document to reflow. The focus is the subject of user interaction in a document (e.g., for entering text, selecting a button, etc.).</p>
<p>Users must keep track of where the focus lies and must also represent the focus. This may be done by using dynamic outlines in conjunction with the <em>:focus</em> pseudo-class.</p>
<h5>Example:</h5>
<p>For example, to draw a thick black line around an element when it has the focus, and a thick red line when it is active, the following rules can be used:</p>
<p><code>:focus  { outline: thick solid black; }<br />
:active { outline: thick solid red; }</code></p>
<h3>The solutions</h3>
<p>The nitty gritty part of the article now. Tested in modern browsers, so please share your experience with your browser.</p>
<h4>Just remove the damn thing</h4>
<p>Gone from every link (kills accessibility):<br />
<code>a { outline: none; }</code><br />
We could apply this to specific CSS selectors instead of the whole site. For example to our header (still kills accessibility a little):<br />
<code>#header a { outline: none; }</code></p>
<p>Oh, wait! We can save the day, using active/focus statuses without losing the accessibility.<br />
Or we can apply outline:none to the active state or use overflow:hidden for text-indent situations:<br />
<code>a:active { outline: none; }</code><br />
or<br />
<code>a{ overflow: hidden; }</code></p>
<p>Gone from every flash object (to be honest I see no accessibility drawback here):<br />
<code>object { outline: none; }</code></p>
<p>Gone from submit buttons or input elements that behave as such (not so bad for accessibility, but not valid):<br />
<code>/* FireFox*/<br />
input[type="submit"]::-moz-focus-inner, input[type="button"]::-moz-focus-inner { border: 0; }<br />
/* IE8 */<br />
input[type="submit"]:focus, input[type="button"]:focus { outline: none; }</code><br />
<small>Source: <a href="http://stackoverflow.com/questions/71074/how-to-remove-firefoxs-dotted-outline-on-buttons-as-well-as-links">Stack Overflow</a></small></p>
<p>There&#8217;s an alternative javascript way, 1st line for links 2nd for input element (which kills all possibility of keyboard use with that input element):<br />
<code>onfocus="this.hideFocus=true;"<br />
onfocus="this.blur()"</code></p>
<p>A quick jQuery kill for links:<br />
<code>$('a').each(function(){this.onmouseup = this.blur();});</code></p>
<p>A longer jQuery kill for links:<br />
<code>$('a').live('mousedown', function(e) {<br />
e.target.blur();<br />
e.target.hideFocus = true;<br />
e.target.style.outline = 'none'<br />
}).live('mouseout', function(e) {<br />
e.target.blur();<br />
e.target.hideFocus = false;<br />
e.target.style.outline = null;<br />
});</code></p>
<p>A long javascript kill:<br />
<code>var runOnLoad = new Array(); // for queuing multiple onLoad event functions<br />
window.onload = function() { for(var i=0; i<br />
// hide dotted :focus outlines when mouse is used<br />
// but NOT when tab key is used<br />
if(document.getElementsByTagName)<br />
for(var i in a = document.getElementsByTagName('A')) {<br />
a[i].onmousedown = function() {<br />
this.blur(); // most browsers<br />
this.hideFocus = true; // ie<br />
this.style.outline = 'none'; // mozilla<br />
}<br />
a[i].onmouseout = a[i].onmouseup = function() {<br />
this.blur(); // most browsers<br />
this.hideFocus = false; // ie<br />
this.style.outline = null; // mozilla<br />
}<br />
}</code><br />
<small>Source: <a href="http://www.mikesmullin.com/javascript/removing-the-dotted-outline-from-focused-links/">Mike Smullin</a></small></p>
<p>I think I saw a CSS way to remove the outline for older IE versions, not sure if it works; but certainly is not valid (in this example for links):<br />
<code>a { noFocusLine:expression(this.onFocus=this.blur()) }</code></p>
<h4>Style it, don&#8217;t kill it</h4>
<p>Instead of killing it, we could just style it (IE6 and IE7 don&#8217;t support this, as they are not modern browsers):<br />
<code>:focus { outline: 4px solid green; }</code><br />
Notice that I used :focus instead of a:focus to make it global, so it applies to form buttons as well and not just links.<br />
<small>Source: <a href="http://haslayout.net/css-tuts/Removing-Dotted-Border-on-Clicked-Links">haslayout.net</a></small></p>
<h3>Putting all together, deciding on best solution</h3>
<p>Personally, I dislike the dotted outlines, but I have to admit accessibility (and usability) should not be ignored. My recommendation after looking at the solutions above would be to do a bit of both; let me call this <strong>kill in style</strong>.<br />
As I don&#8217;t like javascript options, I&#8217;d only use CSS that&#8217;s valid for modern browsers and wait for any comments from you regarding non-modern ones.</p>
<p>Alright! I&#8217;d remove the outlines from specific areas of a design, get rid of them for things that has no use for, and then style it for the areas that would be nice to have it there. For the form buttons, I&#8217;m using a code by <a href="http://www.cssplay.co.uk/menu/nodots.html">Stu Nicholls</a>. Here&#8217;s my final code:</p>
<p><code>#header a:active, object { outline: none; }<br />
:focus { outline: 2px solid green; }<br />
.button { width: your_button_width_in_px; height: your_button_height_in_px; background:url('path_to/your_initial_image'); position: relative; }<br />
.button a img { display: none; }<br />
.button a:hover { background:url('path_to/your_hover_image'); }<br />
.button a:active, .button a:focus { position: absolute; width: 0; height: 0; top: 0; left: 0; }<br />
.button a:active img, .button a:focus img { display: block; width:your_button_width_in_px; height: your_button_height_in_px;}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://stamatiskritikos.com/2010/01/03/remove-dotted-outline-vs-accessibility/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

