<?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>Friendly Bit &#187; JS</title> <atom:link href="http://friendlybit.com/articles/js/feed/" rel="self" type="application/rss+xml" /><link>http://friendlybit.com</link> <description>You have found Friendly Bit, a web development blog. I focus on client side technologies like CSS, HTML and Javascript. You find my articles below and categories to the right.</description> <lastBuildDate>Fri, 05 Feb 2010 23:32:09 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Rendering a web page &#8211; step by step</title><link>http://friendlybit.com/css/rendering-a-web-page-step-by-step/</link> <comments>http://friendlybit.com/css/rendering-a-web-page-step-by-step/#comments</comments> <pubDate>Mon, 11 Jan 2010 00:04:33 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[Browsers]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/?p=580</guid> <description><![CDATA[Have you ever thought about what happens when you surf the web? It&#8217;s not as simple as it seems:You type an URL into address bar in your preferred browser.
The browser parses the URL to find the protocol, host, port, and path.
It forms a HTTP request (that was most likely the protocol)
To reach the host, it [...]]]></description> <content:encoded><![CDATA[<p>Have you ever thought about what happens when you surf the web? It&#8217;s not as simple as it seems:</p><ol><li>You <strong>type an URL</strong> into address bar in your preferred browser.</li><li>The browser <strong>parses the URL</strong> to find the protocol, host, port, and path.</li><li>It <strong>forms a HTTP request</strong> (that was most likely the protocol)</li><li>To reach the host, it first needs to <strong>translate </strong>the human readable host<strong> into an IP number</strong>, and it does this by doing a DNS lookup on the host</li><li>Then a <strong>socket needs to be opened</strong> from the user&#8217;s computer to that IP number, on the port specified (most often port 80)</li><li>When a connection is open, the <strong>HTTP request is sent</strong> to the host</li><li>The host <strong>forwards the request</strong> to the server software (most often Apache) configured to listen on the specified port</li><li>The <strong>server inspects the request</strong> (most often only the path), and <strong>launches the server plugin needed</strong> to handle the request (corresponding to the server language you use, PHP, Java, .NET,  Python?)</li><li>The plugin gets access to the full request, and starts to prepare a HTTP response.</li><li>To construct the response a <strong>database </strong>is (most likely) <strong>accessed</strong>. A database search is made, based on parameters in the path (or data) of the request</li><li>Data from the database, together with other information the plugin decides to add, is <strong>combined into a long string</strong> of text (probably HTML).</li><li>The plugin <strong>combines </strong>that data with some meta data (in the form of HTTP headers), and <strong>sends the HTTP response</strong> back to the browser.</li><li>The browser receives the response, and <strong>parses the HTML</strong> (which with 95% probability is broken) in the response</li><li>A <strong>DOM tree is built</strong> out of the broken HTML</li><li><strong>New requests are made</strong> to the server for each new resource that is found in the HTML source (typically images, style sheets, and JavaScript files). Go back to step 3 and repeat for each resource.</li><li><strong>Stylesheets are parsed</strong>, and the rendering information in each gets attached to the matching node in the DOM tree</li><li><strong>Javascript is parsed and executed</strong>, and DOM nodes are moved and style information is updated accordingly</li><li>The browser <strong>renders the page</strong> on the screen according to the DOM tree and the style information for each node</li><li><strong>You</strong><strong> see</strong> the page on the screen</li><li>You get annoyed the whole process was too slow.</li></ol><p>I, too, get annoyed when the above steps take longer than one tenth of a second. But now at least I have some documentation to look at, while waiting the remaining fractions of a second before the page renders.</p><p><a
href="http://www.flickr.com/photos/amboo213/115034446/sizes/s/"><img
class="alignnone" title="Spoiled dog - by amboo213 on Flickr" src="http://farm1.static.flickr.com/45/115034446_8bf43c2273_m.jpg" alt="Spoiled dog" width="240" height="180" /></a></p><p>Spoiled we are, all of us.</p><p><em>(Feel free to add more steps, through the comments&#8230;)</em></p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/css/rendering-a-web-page-step-by-step/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>Make a div clickable</title><link>http://friendlybit.com/js/make-a-div-clickable/</link> <comments>http://friendlybit.com/js/make-a-div-clickable/#comments</comments> <pubDate>Tue, 30 Jun 2009 20:53:25 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/?p=498</guid> <description><![CDATA[We all dislike that links are so small, and hard to click. So of course we want to make the clickable areas bigger. Some would think that doing this with some CSS on the a-tag would be a good way, but then you can&#8217;t have block level elements inside it (you&#8217;ll get a validation error [...]]]></description> <content:encoded><![CDATA[<p>We all dislike that links are so small, and hard to click. So of course we want to make the clickable areas bigger. Some would think that doing this with some CSS on the a-tag would be a good way, but then you can&#8217;t have block level elements inside it (you&#8217;ll get a validation error if you try to put headings or paragraph tags inside of links). So what&#8217;s a more general solution?</p><p>My take is to use a div instead, and use javascript, of course together with a good fallback. When clicking the div, find the first link inside it, and go to that URL. It&#8217;s simple, and with a few additional quirks, it gets really useful.</p><p>Javascript code (requires jQuery):</p><pre><code >$(document).ready(function(){
   var block = $(".teaser");
   block.click(function(){
      window.location = $(this).find("a:first").attr("href")
   });
   block.addClass("clickable");
   block.hover(function(){
      window.status = $(this).find("a:first").attr("href")
   }, function(){
      window.status = ""
   })
});</code></pre><p>CSS for showing that the div actually is clickable:</p><pre><code >.clickable {
   cursor: pointer;
}
.clickable:hover {
   background: #efefef;
}</code></pre><p>A <a
href="/files/clickable_block/">clickable div demo</a> is of course available.</p><h2>How it works</h2><ul><li>When the div (or other tag, you choose) is clicked, find the <strong>first anchor tag</strong>, get it&#8217;s href attribute, and go there. Relying on an actual link means you always have a fallback, so no cheating.</li><li>When <strong>javascript is disabled</strong>, it just falls back to a regular block, where only the links are clickable.</li><li>A class called &#8220;clickable&#8221; is set on the block to allow for <strong>javascript-specific styling</strong>, such as changing the cursor with cursor: pointer, something you don&#8217;t want to happen when the block isn&#8217;t clickable.</li><li>The changing background color on <strong>hover is done with	 CSS</strong>, which I think is fair, considering the small percentage of users using IE6. Changing background color isn&#8217;t a must feature.</li><li>Lastly, since we&#8217;re simulating a link here, it should show where the link is going. I&#8217;ve done this by setting the statusbar to the link location on hover, something that&#8217;s useful when it works (users can disable this in some browsers).</li></ul><p>Hope that little snippet is useful for someone out there, I think it&#8217;s a good example of good use of javascript.</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/js/make-a-div-clickable/feed/</wfw:commentRss> <slash:comments>27</slash:comments> </item> <item><title>Interface developers and security</title><link>http://friendlybit.com/css/interface-developers-and-security/</link> <comments>http://friendlybit.com/css/interface-developers-and-security/#comments</comments> <pubDate>Fri, 23 Jan 2009 22:30:44 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/?p=398</guid> <description><![CDATA[You live in a new era, when demanding that people register on your site is no longer enough. There&#8217;s far too many other sites out that that you&#8217;re already a member of, you don&#8217;t need another one. You need to trust people.
You also want people to contribute to your sites with content somehow. Text is [...]]]></description> <content:encoded><![CDATA[<p>You live in a <strong>new era</strong>, when demanding that people register on your site is no longer enough. There&#8217;s far too many other sites out that that you&#8217;re already a member of, you don&#8217;t need another one. You need to trust people.</p><p>You also want people to contribute to your sites with content somehow. Text is not enough, you want all kinds of &#8220;rich&#8221; content, and you want people to be able to place them how they want on your page. I mean, we live in a <strong>new era</strong> after all.</p><p>Problem is, this <strong>new era thingie talk</strong> makes people forget the basics. Even though this is the future, and we&#8217;re all bored with &#8220;just&#8221; hypertext, we can&#8217;t allow random people to add HTML to our sites. Why? Ask myspace about the <a
href="http://namb.la/popular/tech.html">Samy worm</a> from 2005, a little piece of clever front-end code that took their servers flying. What did they do wrong? They tried to let untrusted people embed HTML on their profile pages.</p><p>But they even had this clever filter, which cleaned the code first! Well, long story short, using a div with the style attribute set to a background image that points to a javascript url actually execute the javascript in IE6. Didn&#8217;t think of that did you? So what about the fact that both IE6 and IE7 execute vbscripts in urls prefixed with &#8220;vbscript:&#8221;, just like with javascript. Didn&#8217;t know that? Ohhh. Perhaps then you shouldn&#8217;t be trying to let unknown people embed HTML on your site?</p><p>Many of these security issues stem from the fact that ordinary well-educated computer scientists <strong>don&#8217;t know enough about interface development</strong>, HTML, CSS and javascript, and discount them as being something that &#8220;anyone&#8221; could do. &#8220;Even my aunt made this puppy site in like 3 days, how hard can it be?!&#8221;.</p><p>I&#8217;ve always thought that interface development have an undeserved reputation of being easier than &#8220;real programming&#8221;; something that you can let rookies work with, something that no &#8220;real&#8221; programmer would ever want. &#8220;No, I want to work with hard stuff, not that webby stuff&#8221;.</p><p>If you are in a position where people actually think that, perhaps security could be the way to lift interface development to its proper status. So why not read up on <a
href="http://en.wikipedia.org/wiki/Cross-site_scripting">Cross Site Scripting (XSS)</a>, look at <a
href="http://ha.ckers.org/xss.html">examples of vulnerabilities</a>, and pick a couple of examples of <a
href="http://www.xssed.com/">big sites that are vulnerable</a>. While you&#8217;re at it, why not read up on <a
href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">Cross-site request forgery (CSRF)</a> too?</p><p>These are real issues that <strong>someone </strong>needs to take into account when building websites. My guess is that the fancy computer scientists will have a very long way to go before grasping this stuff. &#8220;Why does IE6 parse &#8216;java   script:&#8217; as if there where no space in the middle?&#8221;. You know who&#8217;s not surprised? Every damn interface developer out there.</p><p>So. Go out there, and teach them silly math people how it&#8217;s done, and what your HTML, CSS and javscript-knowledge is worth. Show them that logic isn&#8217;t the way we do things around here, that anything can happen when IE6 boots. And&#8230; whatever you do&#8230; think very hard before letting people embed HTML on your site.</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/css/interface-developers-and-security/feed/</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>Worth a look: DOMAssistant</title><link>http://friendlybit.com/js/worth-a-look-domassistant/</link> <comments>http://friendlybit.com/js/worth-a-look-domassistant/#comments</comments> <pubDate>Mon, 25 Feb 2008 20:30:31 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/js/worth-a-look-domassistant/</guid> <description><![CDATA[A couple of months ago Robert Nyman showed me a javascript library he had built, DOMAssistant, and proceeded to use it successfully in one of our projects. I wasn&#8217;t amused. How could a tiny homebuilt little hack compete with my favorite, the almighty jQuery?
I whined, and said I really liked the CSS-selector syntax that jQuery [...]]]></description> <content:encoded><![CDATA[<p>A couple of months ago <a
href="http://www.robertnyman.com/">Robert Nyman</a> showed me a javascript library he had built, <a
href="http://domassistant.com/">DOMAssistant</a>, and proceeded to use it successfully in one of our projects. I wasn&#8217;t amused. How could a tiny homebuilt little hack compete with my favorite, the almighty jQuery?</p><p>I whined, and said I really liked the CSS-selector syntax that jQuery has. So <a
href="http://www.robertnyman.com/2007/12/17/domassistant-25-released-css-selector-support-new-ajax-methods-and-more-goodies-added/">he added support for CSS1, CSS2, and CSS3</a>. The bastard.</p><p>After a while he started getting doubts about if he really could compete with the big names, being supported by lots of people. But instead of giving up he got himself <a
href="http://domassistant.com/about/">a team of his own</a>. The famous <a
href="http://www.456bereastreet.com/about/">Roger Johansson</a> being one of them. There went that argument, damnit!</p><p>I pointed out the jQuery was very small, only 15 kb! He pointed out that DOMAssistant is half that size, 7 kb. That&#8217;s smaller than most images. Aaaargghh!</p><p>I said that jQuery is much faster than anything I&#8217;ve seen. He showed me the <a
href="http://www.domassistant.com/slickspeed/">slickspeed</a> test, showing that his framework was indeed faster than all the others. How could he do that? Well, he explained, by using the browser optimized XPath and querySelectorAll support in browsers.</p><p>I had one card left to play, a somewhat ugly one. &#8220;Animations?&#8221; I almost wispered. &#8220;No&#8230;&#8221; came the reply back. But as he saw me straighten my back, getting ready to proclaim victory, he contiuned &#8220;&#8230; but it&#8217;s being worked on, and coming in the next release&#8221;. Damn you Robert, it seems I just have to give it a try&#8230;</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/js/worth-a-look-domassistant/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Sharepoint 2007 from an interface developer&#8217;s view</title><link>http://friendlybit.com/css/sharepoint-2007-from-an-interface-developers-view/</link> <comments>http://friendlybit.com/css/sharepoint-2007-from-an-interface-developers-view/#comments</comments> <pubDate>Sun, 20 Jan 2008 11:10:42 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/css/sharepoint-2007-from-an-interface-developers-view/</guid> <description><![CDATA[Like Cameron Moll (Skinning Sharepoint and Pointedly unskinnable), I&#8217;ve been working with Sharepoint 2007 (aka MOSS) recently, and I hope you don&#8217;t mind me posting a few articles about my work here. I&#8217;ve found far too few blog posts that really go to the depth in explaining how things really work. I&#8217;ll try to do [...]]]></description> <content:encoded><![CDATA[<p>Like Cameron Moll (<a
href="http://cameronmoll.com/archives/2007/05/skinning_ms_sharepoint_with_st/">Skinning Sharepoint</a> and <a
href="http://cameronmoll.com/archives/2007/10/sharepoint_2007_pointedly_unskinnable/">Pointedly unskinnable</a>), I&#8217;ve been working with Sharepoint 2007 (aka MOSS) recently, and I hope you don&#8217;t mind me posting a few articles about my work here. I&#8217;ve found far too few blog posts that really go to the depth in explaining how things really work. I&#8217;ll try to do that here, but I hope you can respect my wish that this does not turn into a helpdesk.</p><h2>&#8220;Customization&#8221;</h2><p>Let&#8217;s start. <strong>Sharepoint 2007 very, very hard to customize</strong>. If your job is to customize the interface in any major way, you have a lot of work ahead of you. You might think you&#8217;re a much better interface developer than me, but you still have a lot of work ahead of you. You need to accept that.</p><p>When you read about Sharepoint 2007 on other sites you will find that people are really ecstatic about it. Just check the comments on how to <a
href="http://planetwilson.blogspot.com/2007/09/sharepoint-2007-colour-color-calendar.html">customize the calendar</a>. Reading carefully you will find that he&#8217;s comparing it with Sharepoint 2003, not with other products, or even a standard ASP.NET site. That&#8217;s a big difference. Sharepoint 2003 was much worse, but that does not mean things are good now. This is a common pattern, people that like Sharepoint compare it to the previous version, not with better ways of doing things.</p><p>As most CMS:es, Sharepoint gets sold to customers that don&#8217;t know programming. They see a product that can handle all the features they want: blogs, wikis, forums, calendars, document libraries, workflows, and so on. All features you could ever want is included, from what is called &#8220;out of the box&#8221;. The problem is that the system is built so that all of those &#8220;out of the box&#8221; features are hard to customize. Things like changing how the wiki renders, is really hard. Often it&#8217;s easier to rebuild that feature from scratch, than customizing what Sharepoint ships.</p><p>This is the main reason, from my point of view, that you should pick another CMS.</p><h2>Specifics</h2><p>I don&#8217;t believe you trust me on my words, so I thought I&#8217;d be more specific now, and talk about the issues that make Sharepoint 2007 hard to work with (customize). Let me stress that these are not all the issues, just the major ones that an interface developer has to tackle.</p><h3>Development</h3><p>From what I&#8217;ve read from larger projects, the recommended development environment for a Sharepoint site is a virtual machine. For us, we needed a 36 Gb image, a size that required me to get a new external hard drive, just to store it. Also, running in a virtual machine means that you only can use about half of your RAM, which means everything gets slow. As if that wasn&#8217;t enough, a new virtual machine means you have to reinstall all your programs, browsers, plugins again. Web development shouldn&#8217;t have to be like that.</p><h3>Accessibility</h3><p>Sharepoint has gotten a lot of bashing for not being accessible, so they&#8217;ve added <a
href="http://blogs.msdn.com/sharepoint/archive/2006/04/24/582506.aspx?harrison">some features</a> to account for that. Some of those are really good individually, but looking at the general mess that is the HTML that Sharepoint spits out, the pretty page above fades in importance. One major problem is that you still need <strong>javascript enabled</strong> for many of the accessibility features. Enabling &#8220;Accessibility mode&#8221;, among other things, makes dropdown menus appear as new windows (popups) instead of dynamically writing HTML to the page. And this is after they &#8220;fixed&#8221; it.</p><h3>Page size</h3><p>A standard Sharepoint site uses lots of default Javascript and CSS in two files called core.js and core.css. All in all they add up to over 250 kb. Yes, that&#8217;s not a misspelling or extra zero, a default page in sharepoint takes at least 250 kb. This is not counting the HTML, a huge, table-ridden, inline-javascripted, mess of things.</p><p>If you go through lots of trouble, you can strip those files out, but that means you can&#8217;t use any default components. Since much of Sharepoint depend on those, you don&#8217;t really want to go that way. It&#8217;s a mess, and Microsoft themselves recommend you try to <a
href="http://msdn2.microsoft.com/en-us/library/bb727371.aspx#MOSS2007OptPerfWCM_PagePayloadSmallisGood">remove some of it</a> to boost performance. Preferably by using AJAX to load the js file later. Seriously.</p><h3>Javascript and Browser dependencies</h3><p>Except from core.js, the javascript is spread out all over the place. As usual in many CMS:es, javascript is not treated as a real programming language, so there&#8217;s no structuring whatsoever. Sometimes it&#8217;s script tags, sometimes inline, sometimes external mini files, and most often automatically generated code. It&#8217;s a real mess, and is a big reason for the HTML size being so large. Many of the scripts do not work in browsers other than IE, which means you really need IE to properly use the admin interface.</p><p>From the <a
href="http://blogs.msdn.com/sharepoint/archive/2006/07/19/improvements-in-web-browser-compatibility.aspx">browser compatability info</a> you can read that there are level 1 and level 2 browsers:</p><blockquote><p>&#8220;Level 2 web browsers support all of our basic functionality so that users can both read and write in our content sites, perform site administration, etc.  Some functionality may not be available, some functionality may be available in a more limited form, and some visual rendering may not be as optimized as our Level 1 browsers.  We also will not support Level 2 web browsers on the Central Administration site.&#8221;</p></blockquote><p>These are the Level 2 browsers: Firefox, Netscape, Safari. Opera isn&#8217;t even in the list. Is this the new, modern way, of handling cross browser compatibility?</p><h3>Changing the CSS</h3><p>I previously said that most CSS is included in a file called core.css. The file in itself if huge, with thousands of class names, and no structuring whatsoever. Heather Solomon has made an attempt to make things workable by <a
href="http://www.heathersolomon.com/content/sp07cssreference.htm">making images of what each class specifies</a>. It&#8217;s not even nearly a complete reference, and helps some, but using <a
href="http://getfirebug.com/">Firebug </a>is a faster way. Another thing the CSS sheet above does, is show how completely unorganized the CSS is. Have a look at it.</p><p>As with core.js you can&#8217;t really remove core.css, since lots of built-in functionality depends on it. So what you need to do is start deciding which of those rules you need to overwrite and which not. Have fun!</p><p>To add to the insult, if you just add your own CSS as an external file and try to link to that on your own pages, core.css is appended as the last stylesheet in the source code. This of course means that all your changes get overwritten, and you need to hack around things by using the &lt;link&gt; tag directly (instead of sharepoint&#8217;s own csslink-control), or add your custom files via the admin interface. Since core.css is just a list of simple class names, you can also use <a
href="http://www.htmldog.com/guides/cssadvanced/specificity/">CSS Specificity</a> to make your rules count, but that isn&#8217;t mentioned in any of the troubleshooting blog posts. None the less, it&#8217;s tedious do work around.</p><h3>Share point and Master pages</h3><p>Most of Sharepoint is upgraded to use .NET 2.0, and its concept of Master pages and aspx pages. For those of you that don&#8217;t develop in .NET the two can be explained as a templating mechanism, where each Master page has general placeholders where you can insert aspx pages. In each aspx page you specify one master page, and all of the placeholders you want to fill with content. It&#8217;s a pretty good system.</p><p>Sharepoint taps into this system by making up two strings &#8220;~masterurl/custom.master&#8221;, and &#8220;~masterurl/default.master&#8221;, that you use instead of specifying your own masterpages. Users then specify masterpages in the admin interface, potentially breaking the entire site. Also, Sharepoint assumes there&#8217;s just one masterpage per site, so if you thought you could use one masterpage for twocolumn layouts, and another for threecolumn layouts, you&#8217;re wrong. The solution here is to break out of the Sharepoint way and hardcode real urls instead of doing things the Sharepoint way.</p><p>There&#8217;s also things you can&#8217;t change. The admin interface has a masterpage called application.master, which controls pretty much everything that has to do with built-in Sharepoint things. You don&#8217;t ever change this file, since it&#8217;s quite easy to seriously break things then. The problem is that this file also specify the look and feel of the admin interface, and if you&#8217;re building a site where people are expected to add stuff, they will spend time in the admin interface. There isn&#8217;t a good way around this, and you probably end up just changing some colors via CSS and let it be.</p><h3>Default .NET controls</h3><p>The default master pages that ship with Sharepoint is horrendous and I&#8217;ll post more details about them in a later post. But even if you roll your own master pages from scratch you still have the standard .NET-problem with controls. Using controls in .NET is a way to package functionality that you can easily add to your pages. A developer just needs to copy a DLL file, and call the control, optionally sending in some parameters. Easy.</p><p>The problem with this approach is that a control consists both of logic and HTML. So if you want some built-in logic that renders, say, the breadcrumb trail, you also get the HTML the author of the control deemed appropriate. In Sharepoint, a breadcrumb trail can be a doubly nested table, with display: none; controls to enable accessibility, and a doubly span nested link. It&#8217;s just a terrible mess, but there&#8217;s no other way to get to the breadcrumb logic, except from building a new control from scratch. Be prepared to work with terrible HTML.</p><h2>In summary</h2><p>If you want to examine the points above by yourself, there&#8217;s a MOSS example site up at <a
href="http://www.wssdemo.com/default.aspx">wssdemo.com</a>.</p><p>This article is a interface developer view at Sharepoint 2007. If you look at the system from other viewpoints, I&#8217;m sure there are good things there. That&#8217;s not my point. What I&#8217;m trying to say is that <strong>Sharepoint 2007, is beyond repair when it comes to interface customization</strong>, and you should do everything in your power to avoid working with it. If I can give one interface developer the arguments to convince a customer to pick another system, this article was worth it. Thanks for reading.</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/css/sharepoint-2007-from-an-interface-developers-view/feed/</wfw:commentRss> <slash:comments>29</slash:comments> </item> <item><title>Manipulating innerHTML removes events</title><link>http://friendlybit.com/js/manipulating-innerhtml-removes-events/</link> <comments>http://friendlybit.com/js/manipulating-innerhtml-removes-events/#comments</comments> <pubDate>Wed, 26 Sep 2007 22:24:04 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/js/manipulating-innerhtml-removes-events/</guid> <description><![CDATA[Others have written about this before, but I thought I&#8217;d mention it again, just so you don&#8217;t miss it. Aleksandar Vaci? found it while playing with tables and their cells. I found it when Robert and I played with nested lists. It works the same across browers. Let me show a quick example:
You have a [...]]]></description> <content:encoded><![CDATA[<p>Others have written about this before, but I thought I&#8217;d mention it again, just so you don&#8217;t miss it. <a
href="http://www.aplus.co.yu/scripts/innerhtml-kills-event-handlers/">Aleksandar Vaci?</a> found it while playing with tables and their cells. I found it when <a
href="http://www.robertnyman.com/">Robert</a> and I played with nested lists. It works the same across browers. Let me show a quick example:</p><p>You have a paragraph tag that contains a span that you want to make clickable.</p><pre><code >&lt;p id="para"&gt;
   &lt;span id="clickspan"&gt;This is clickable.&lt;/span&gt;
   But this is not.
&lt;/p&gt;</code></pre><p>To make it clickable you don&#8217;t do any fancy stuff, you just add it with onclick:</p><pre><code >var span = document.getElementsById("clickspan");
span.onclick = function() {
   alert("You clicked the span!");
}</code></pre><p>All fine. You click the span and it just works. But then you remember something. You want to add some text to the end of the paragraph, and you decide to do this with javascript. You add the following line to the end of the script:</p><pre><code >var p = document.getElementById("para");
p.innerHTML += " Some extra text";</code></pre><p>You try clicking the span again, and it doesn work. You scratch your hair, you bite your nails, you scream of desperation and anger. It still doesn&#8217;t work. It seems manipulating an element by using innerHTML removes all events from that element, and all children. Here&#8217;s a <a
href="/files/innerHTMLevents/">live example</a>. I thought you should know.</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/js/manipulating-innerhtml-removes-events/feed/</wfw:commentRss> <slash:comments>16</slash:comments> </item> <item><title>I&#8217;m an interface developer</title><link>http://friendlybit.com/css/im-an-interface-developer/</link> <comments>http://friendlybit.com/css/im-an-interface-developer/#comments</comments> <pubDate>Mon, 20 Aug 2007 22:17:55 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/css/im-an-interface-developer/</guid> <description><![CDATA[In his latest post Roger Johansson asks the question Are we designers or developers?. I have a simple answer for that. None of them. Let me explain:
First we have these people calling themselves developers. And boy do they know programming&#8230; and math&#8230; and&#8230; no that&#8217;s all. Many have a masters degree in computer science, a [...]]]></description> <content:encoded><![CDATA[<p>In his latest post Roger Johansson asks the question <a
href="http://www.456bereastreet.com/archive/200708/are_we_designers_or_developers/">Are we designers or developers?</a>. I have a simple answer for that. <strong>None of them</strong>. Let me explain:</p><p>First we have these people calling themselves <strong>developers</strong>. And boy do they know programming&#8230; and math&#8230; and&#8230; no that&#8217;s all. Many have a masters degree in computer science, a degree that pretty much tells you that they once gave five years of their lives to programing, how cool is that!? It&#8217;s not unusual to find people that <a
href="http://xkcd.com/55/">think in those terms</a> too. You can recognize them by their 10 year old, unmatched, clothes and you&#8217;ll rarely talk more than 1 minute with them. Very efficient.</p><p>Then we have the <strong>designers</strong>. Either real females, or people very close to females, that just can&#8217;t stop talking about this abstract thingie-thongie that just like, you know, exploded in a big burst of colors and like&#8230; &#8220;EHEM! Sorry!&#8221;, you hear them say, regaining consciousness and flying back to earth. Their clothes, at least you think they are clothes, often look like they where meant for something else. Perhaps for building steel pumps, or killing animals&#8230; or both. Well, at least these clothes are matched&#8230; or very purposefully not at all matched (not at aaaall like the developers). You can talk with these people for hours, probably even days, and still only touch upon the delicate topic of &#8220;a glass of water&#8221;. Oh, and they &#8220;create&#8221; things too. Very deep.</p><p>So where the heck does the <strong>interface developer</strong> come into all of this? Well, imagine you have a real project at hand. Real people that need some new website to do their work. Real deadlines, money that switches hands. Smiling business people that promises things and shake hands. Seems like something you know of?</p><p>Now, imagine bringing a developer and a designer together in a room, for like a month, working together with this new website. Concentrate hard and try to see the images before your very eyes. Will they accomplish anything?</p><ol><li><strong>Hell no!</strong> In 5 minutes they will have started arguing about who should be the first one to open the door, and in what way. One talking about the most efficient way to turn the handle, and the other one defending herself by talking about cosmic beams from Saturn. After the first day the developer will have sore cheeks, after being constantly bitch slapped while hiding under his desk. The third day the designer will sit shaking in a corner after the electric shock induced by the steel helmet the developer built. None of them will survive the fourth day, let alone the project.</li><li><strong>Very yes!</strong> When you meet them after the month has passed you find two harmonic people that smiles to each other and really seem to have connected. They explain to you that the demonstration will be in two parts, first the designer and then the programmer. The designer shows you an app that really touches you, at least you think so, although you not fully understand it. The programmer shows you the other part of the app, one that instantly shows the number 369. They finish the presentation and look at you. You stand up, walk out, lock yourself into a nearby free conference room, and shout with all the power in your lungs: &#8220;HOW THE F*#CK AM I GOING TO DO MY TAXES WITH THIS SHIT?!#&#8221;. When you come back you find them congratulating each other for making the deadline.</li></ol><p>You see? There&#8217;s something missing there. Some kind of link between the two. Someone that can walk into a room with two screaming people and calmly say: &#8220;Hey, you both kinda run linux (SuSE vs. Mac OS X), and have a &#8220;cold&#8221; desktop background (default plain blue vs. modern interpretation of <a
href="http://en.wikipedia.org/wiki/Image:Vasnetsov_Snegurochka.jpg">Vasnetsov Snegurochka</a>), what a coincidence!?&#8221;. There needs to be someone that can walk into the same room the next day and explain that they are talking about two different kinds of &#8220;abstract methods&#8221;. There needs to be a link.</p><p>But there&#8217;s more: An interface developer is silly enough to learn languages that doesn&#8217;t even have variables. Even though he know that his code will be sent as uncompressed plaintext and will be rendered by broken excuses for programs, he won&#8217;t cry himself to bed every night.</p><p>He will also gladly adapt a design to something it wasn&#8217;t really intended for, and he even will make it look somewhat good. He will skip adding those fabulous shadows, to make the deadline on time, and still think of himself a good person.</p><p>You see, even though &#8220;interface&#8221; reflect the visual graphic things, and &#8220;developer&#8221; relate to hard logic code, <strong>interface developers</strong> are real people, not a combination of two halves. I am one.</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/css/im-an-interface-developer/feed/</wfw:commentRss> <slash:comments>17</slash:comments> </item> <item><title>What is Web 2.0? Really.</title><link>http://friendlybit.com/js/what-is-web-20-really/</link> <comments>http://friendlybit.com/js/what-is-web-20-really/#comments</comments> <pubDate>Fri, 09 Mar 2007 23:59:52 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[JS]]></category> <category><![CDATA[Tutor]]></category><guid
isPermaLink="false">http://friendlybit.com/js/what-is-web-20-really/</guid> <description><![CDATA[Web 2.0 is really hot right now. One of Sweden&#8217;s biggest newspapers recently wrote a long article on their debate section. They had started linking back to blogs that linked to them, in a little box next to the article. The problem was that they had got into trouble with what blogs to link to. [...]]]></description> <content:encoded><![CDATA[<p>Web 2.0 is really hot right now. One of Sweden&#8217;s biggest newspapers recently wrote a long article on their debate section. They had started linking back to blogs that linked to them, in a little box next to the article. The problem was that they had got into trouble with what blogs to link to. After all, you can&#8217;t just link to anything, right?</p><p>Aside from starting to think about the implications of blog links, I got another interesting question in my head. What is Web 2.0 really? Most people working with interface development would say that Web 2.0 is everything that uses AJAX. But the newspaper didn&#8217;t use AJAX at all, and still they claim links to blogs is Web 2.0. Time for some research!</p><h2>The hunt for a definition</h2><p>The phrase &#8220;Web 2.0&#8243; was first put into widespread use at an O&#8217;Reilly conference in 2004. The organisers wanted to talk about a change that has happened on the web, and just bumping the version of the web seemed like a good idea. Paul Graham found this <a
href="http://www.paulgraham.com/web20.html#f1n">first try at defining Web 2.0</a> at the conference:</p><blockquote><p>&#8220;While the first wave of the Web was closely tied to the browser, the second wave extends applications across the web and enables a new generation of services and business opportunities.&#8221;</p></blockquote><p>Note that there&#8217;s no mention of AJAX there. Hell, there&#8217;s no mention of users either! They must have meant something else, and the definition might have changed over the years since then. Let&#8217;s keep looking for a good definition.</p><p>Tim O&#8217;Reilly comments on the issue two years later, in a <a
href="http://radar.oreilly.com/archives/2006/12/web_20_compact.html">clairification on his blog</a>:</p><blockquote><p>Web 2.0 is the business revolution in the computer industry caused by the move to the internet as platform, and an attempt to understand the rules for success on that new platform. Chief among those rules is this: Build applications that harness network effects to get better the more people use them.</p></blockquote><p>Tim acknowledges the change in meaning and talks about &#8220;network effects&#8221; here, something that starts to look a little bit more like what my idea of Web 2.0 is. But isn&#8217;t there still something missing? To me, that looks only like a small part of what I call Web 2.0. Let&#8217;s keep looking&#8230;</p><p>Gartner has tried to convince companies of the merits of Web 2.0 for a rather long time. In one of their many (business oriented) PowerPoint presentations they attempt to define &#8220;three anchor points around Web 2.0&#8243;:</p><blockquote><ul><li><strong>Technology and Architecture</strong> — Consisting of Web-oriented architecture (WOA) and Web platforms.</li><li><strong>Community</strong> — Looks at the dynamics around social networks and other personal content public/shared models, wiki and other collaborative content models.</li><li><strong>Business Model</strong> — Web service-enabled business models, mashup/remix applications and so forth.</li></ul></blockquote><p>I believe we&#8217;re getting closer. Gartner is making business models a separate point which I don&#8217;t agree with. Many of the biggest Web 2.0 sites didn&#8217;t have a business model when they started (and many still don&#8217;t). Digg has troubles covering their hosting cost with the tiny bit of money they acquire from their ads. Del.icio.us still doesn&#8217;t make any direct money (although they got sold to Yahoo, and they surely use the data&#8230;). My point is, a business plan isn&#8217;t one third of Web 2.0, it&#8217;s something sites add afterwards if things work out.</p><p>So let me state my own (slightly more general) definition of Web 2.0:</p><blockquote><p>&#8220;A collection of ideas and techniques that can be used to make more interactive sites&#8221;</p></blockquote><p>The thing is, just doing something in AJAX does not mean it gets the Web 2.0 stamp of approval. You need several of the ideas or techniques and you need to combine them in clever ways. So lets agree on the definition above and got look for ideas.</p><h2>Ideas that are part of Web 2.0</h2><p>I&#8217;d like to gather a whole bunch of ideas under the Web 2.0 roof. My selection is of course not all there is. Googling could uncover more I&#8217;m sure, but I think this is a good start.</p><ul><li><a
href="#generated">User generated content</a></li><li><a
href="#trust">Radical trust</a></li><li><a
href="#syndication">Syndication of content and services</a></li><li><a
href="#tail">Long tail</a></li><li><a
href="#collective">Collective intelligence</a></li></ul><h3 id="generated">User generated Content</h3><p>Many companies still view the web as a one-way medium, an extension of a paper catalogue, it&#8217;s main advantage being that it can be distributed to more people. It&#8217;s not like that any more! There are people that want to add content to your site, that want to contribute their ideas and thoughts. Why are you denying them to help you?</p><p>User generated content is content that your users are willing to give you. It can be everything from a simple &#8220;like it&#8221; or &#8220;don&#8217;t like it&#8221;, to fully featured articles written by users. The two most used ways of contributions are the simple ones: votes and comments. The author is still in full control of the content but users are given a chance to chip in with minor corrections. This is the least you can do. It&#8217;s what I do on this blog; let you chip in by commenting.</p><p>But if you have users that are passionate about your subject, users that are willing to use your site to get their ideas out, you should really endorse that! Allow them to post articles on your site, allow them to regroup and reprioritize according to their own wishes. It is technically possible, even rather easy to do; you just have to do it.</p><p>Six simple things your users can help you with:</p><ul><li>Reviews of your products</li><li>Comments on your articles</li><li>Stories about how people use your product</li><li>Multimedia using your product</li><li>Questions about your products</li><li>Articles in an area you choose</li></ul><h3 id="trust">Radical trust</h3><p><img
src="/files/web20/wikipedia.png" alt="Logotype of Wikipedia" class="secondary"><br
/> Another approach many sites have taken can be summarized as &#8220;radical trust&#8221;. It builds on the simple idea that users know what they want better than you do. So let them order, categorize, sort, select your data as they like!</p><p>This is exactly what wikis do. They acknowledge that there are more users doing good than doing bad. If that&#8217;s the case, why not let them in on your content directly, letting them edit and improve it like they want. They few people that do bad can be hunted away with a combination with versioning (saving old versions of content that&#8217;s easy to restore), and some simple monitoring. Wikis trust users, do you?</p><h3 id="syndication">Syndication of content and services</h3><p>Web 2.0 is not only about &#8220;user to website&#8221; interactivity. It&#8217;s also about letting other sites and tools interact with your site directly. This is often summarized as &#8220;syndication&#8221;.</p><p>It&#8217;s a very fancy word for a simple concept. Let me try to explain.</p><p>Somewhere you have some kind of database with your content, be it products in your e-store or posts on your blog. Usually you take that content, add some structure (HTML) to it, and send it to the user.</p><p>Another website that wants to access the same information could parse the HTML and try to understand what it means, something called &#8220;screen scraping&#8221; (or microformats ;). The problem with that method is that it&#8217;s very dependent on that the webmaster doesn&#8217;t decide to change the HTML. The other problem is that computers and humans often want different types of information. A computer that is going to parse a list of your products doesn&#8217;t need navigation like humans do. What you do is send your data directly to computers instead, without messing it up with HTML. Formats include: RDF, RSS, or perhaps custom XML through a Web Service.</p><p>Thing is, when you start syndicating your data you make it easier for others build services based on it. Now people get several entrances into your content instead of the one you produced. Again, your users are helping you reach more people.</p><p>Allowing full RSS feeds is another way of syndicating, I&#8217;m switching right now. Do you syndicate?</p><h3 id="tail">Long tail</h3><p><img
src="/files/web20/tail.png" alt="Graph of a sold units per item" class="secondary"><br
/> The theory of the long tail is one of the ideas that are usually associated with Web 2.0. It&#8217;s a business model that many companies that are successful on the web use. As with most business models they are invented after the fact, and as such I&#8217;m not sure it really belongs on this list, but people always bring it up, so let’s go. I&#8217;ll let you choose yourself.</p><p>Wikipedia describes the long tail like this:</p><blockquote><p>&#8220;Products that are in low demand [...] can collectively make up a market share that rivals or exceeds the relatively few current bestsellers and blockbusters, if the store or distribution channel is large enough&#8221;</p></blockquote><p>Most physical stores need to aim for the bestsellers to sell anything. There&#8217;s simply too few interested in odd products, to make it worth hiring store space and personnel to sell it.</p><p>Web based stores are in a different position. Selling another product usually means just adding another page to your site, no extra store space or personnel needed. In addition people are prepared to wait a couple of days before receiving their products. That time span means you can skip warehouses and not start producing your products until you have an order ready.</p><p>No more is there a need to estimate what people will be interested in and pre-order them. For the right kind of product the internet is a huge benefit. Amazon did it with books, iTunes did it with music, do you do it?</p><h3 id="collective">Collective intelligence</h3><p>You have let each user customize their experience and add content of their own. Now it&#8217;s time to organise that content to better help the everyone benefit from it. There&#8217;s hundreds of ways of doing it, but here&#8217;s a couple of things that you can present to your users:</p><ul><li><strong>The most popular swedish article right now&#8230;</strong> &#8211; Crawl all Swedish blogs and keep track of what they link to.</li><li><strong>Others that bought this book also bought&#8230;</strong> &#8211; Query your shipment table. Pick a product, select the number of times each other product appeared together with said product, and recommend that product to your customers. Amazon does this and it&#8217;s said that it has increased their profits considerably.</li><li><strong>You probably think this movie is a four out of five</strong> &#8211; A Swedish movie site give its users personalized ratings of movies. They find users that have similar taste as you have (based on your previous grades) and then checks what those people have rated the movie as.</li><li><strong>This is probably spam</strong> &#8211; Write a word filter that learns what is considered spam when users mark them. Share that filter with fellow users and let their markings stop your spam. A form of collective sieve filtering, Akismet does this.</li></ul><p>None of them are technologically hard to do, you just Google and copy other people&#8217;s samples. Why not?</p><h2>Techniques involved in Web 2.0</h2><p>But there are techniques involved too. Let&#8217;s go through a few of the important ones.</p><ul><li><a
href="#ajax">AJAX (and other javascript)</a></li><li><a
href="#feeds">Feeds (RSS, Atom)</a></li><li><a
href="#tags">Tags</a></li></ul><h3 id="ajax">AJAX (and other javascript)</h3><p>Everyone talks about AJAX together with Web 2.0, but I think it&#8217;s important they are kept separate.</p><p>AJAX is just a technology that helps prevent (full) page reloads. Instead you connect to the server silently in the background and receive your data that way. What&#8217;s the revolutionary about this technique? Nothing. It has been in use for at least 5 years. They new thing about it is that people started using it to build better interfaces.</p><p>Javascript is language that enables AJAX, and playing with reloads is not all it can do. Through some nifty use you can change attributes on any HTML element on the page. Move things around, react to mouse movement, fade and animate, it&#8217;s your choice. This means a lot of new controls become possible, ranging from simple sliders to interactive maps.</p><p>Why do most accessibility people hate it? Because most developers don&#8217;t know enough about accessibility. And when those start to use AJAX they disregard accessibility completely. Javascript and AJAX have different goals and I think a good compromise is making sure the basic functions of the site (buy a product and pay for it) works without javascript, but enabling it adds additional features.</p><p>When was the last time you used javascript to enhance your site? What was the last control you invented?</p><h3 id="feeds">Feeds (RSS, Atom)</h3><p><img
src="/files/web20/feeds.png" alt="The official feed icon" class="secondary"><br
/> Feeds are great for syndication of content. There are many different feed formats to choose from but they all have one purpose: to communicate pure data, skipping all design.</p><p>A feed is simply a list of feed items, each with an unique identifier. A user adds the address to their &#8220;feed reader&#8221; and it starts polling you, asking for updates. I have my reader set to just a couple of minutes, making sure I quickly notice changes in people&#8217;s feeds.</p><p>The good thing about feeds is that they make it easy to follow several at once. There&#8217;s no annoying different designs in the way if you don&#8217;t want to (you can always just visit the site if you want design). Feeds are getting more and more of a commodity; you should already be allowing your users the possibility to subscribe your content. Do you?</p><h3 id="tags">Tags</h3><p>Tags is another hip concept. It deals with the collective intelligence idea and how to categorize content efficiently. A tag consists of a phrase of some kind that describes a piece of content. This blog post could have the tag &#8220;javascript&#8221;.</p><p>There&#8217;s several ways you can use them. One is the just fix what tags are allowed and use them as regularly groups you can assign content to. But allowing more than one tag enable you to do more than just split things into groups, you can instead pick all contents bits that have the same tag. You can go further, allowing custom tags that the users can pick themselves. That gives you a wide array of descriptive words for your content, free to play around with. For example, if many users pick the same word, that one is probably a better descriptor.</p><p>Picking many bits of content and analysing all tags tied to them can be easily done with a tag cloud. In that you simply print all tags used after each other, and make those used often bigger. Doing this on a whole site is an effective way of giving users a snapshot of what you write about, something I know I like.</p><p>Can tags help you solve a categorization problem you have?</p><h2>Summary</h2><p>Now. To build a Web 2.0 site, pick from both of the lists above. You Google for more ideas and you work hard to interact with your users as much as possible. Web 2.0 is the combination that happens when your ideas and technology finally just works.</p><p>Your users want to help you, do you let them in?</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/js/what-is-web-20-really/feed/</wfw:commentRss> <slash:comments>17</slash:comments> </item> <item><title>Improving interactivity with Javascript</title><link>http://friendlybit.com/js/improving-interactivity-with-javascript/</link> <comments>http://friendlybit.com/js/improving-interactivity-with-javascript/#comments</comments> <pubDate>Wed, 21 Feb 2007 21:13:21 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/js/improving-interactivity-with-javascript/</guid> <description><![CDATA[Push buttons, radio buttons, check boxes, select boxes, and text inputs. That&#8217;s the controls HTML allows us to use to interact with our users.
A small dedicated group of people at the office (I work at Valtech) sat down and listed all controls we could think of. The list below is basically that list, completed [...]]]></description> <content:encoded><![CDATA[<p>Push buttons, radio buttons, check boxes, select boxes, and text inputs. That&#8217;s the controls HTML allows us to use to interact with our users.</p><p>A small dedicated group of people at the office (I work at <a
href="http://www.valtech.se">Valtech</a>) sat down and listed all controls we could think of. The list below is basically that list, completed with examples where possible. Let me stress that the below controls are meant as <strong>inspiration</strong>. They are not all free, or even available for download. If you decide to use one of the ideas, google for them first and pick the best one. While selecting one, make sure it supports some kind of fallback for users without javascript enabled.</p><h2>Slider</h2><p>Slider control meant to let users select values from a range of options.</p><p><a
href="http://webfx.eae.net/dhtml/slider/slider.html"><img
src="/files/ajaxexamples/slider.png" alt="Slider control"></a></p><h2>Date picker</h2><p>What format should this date be? What weekday is the 15:th of august? A good date picker helps the user answer those questions and makes filling in dates much more delighful.<br
/> <a
href="http://www.basicdatepicker.com/"><img
src="/files/ajaxexamples/datepicker.png" alt="Date picker"></a></p><h2>Smart text boxes</h2><p>It&#8217;s easy to make some text boxes only allow certain kinds of characters. Why allow letters in the age field?<br
/> <a
href="http://www.cambiaresearch.com/c4/029c978b-aac5-472e-97a8-95b256f5febd/How-Can-I-Use-Javascript-to-Allow-Only-Numbers-to-Be-Entered-in-a-TextBox.aspx"><img
src="/files/ajaxexamples/smarttextbox.png" alt="Text box that only allows numbers"></a></p><h2>Mixing text inputs with select boxes</h2><p>Allow users to both input text and pick common options.</p><p><a
href="http://www.google.com/webhp?complete=1&#038;hl=en"><img
src="/files/ajaxexamples/gsuggest.png" alt="Google Suggest"></a></p><p><a
href="http://www.extratasty.com/submit"><img
src="/files/ajaxexamples/extratasty.png" alt="Ingredience picker with AJAX"></a></p><h2>Drag and Drop</h2><p>Users are used to dragging and dropping things from their operating systems. Letting them do the same on the web makes for a great affect! Don&#8217;t forget about a fallback though, not everyone uses a mouse (A buy-button is enough).</p><p><a
href="http://demo.script.aculo.us/shop"><img
src="/files/ajaxexamples/dragdrop.png" alt="Example shop with drag and drop"></a></p><p><a
href="http://www.panic.com/goods/"><img
src="/files/ajaxexamples/panic.png" alt="Real shop with drag and drop"></a></p><h2>Collapse and expand control</h2><p>Makes it possible to quickly show less important information on demand. Just make sure everything is open by default (with no javascript).</p><p><a
href="http://www.dustindiaz.com/basement/block-toggle.html"><img
src="/files/ajaxexamples/expand.png" alt="Toggling a block is easy"></a></p><h2>Advanced tooltips</h2><p>When the title attribute is not enough. Use images, fine-tune the delay, make them sticky if you click them, it&#8217;s all up to you!</p><p><a
href="http://blog.innerewut.de/files/tooltip/demo.html"><img
src="/files/ajaxexamples/tooltip.png" alt="Tool tips with a little spice"></a></p><h2>Autosaving form fields</h2><p>If you write an email with <a
href="http://www.gmail.com">Gmail</a> and the browser crashes, you&#8217;ll appreciate that Gmail automatically saves your text regularly. It&#8217;s done with a simple piece of javascript that periodically sends all your text off to the server, and saves it away. Simple and <strong>very</strong> useful.</p><h2>Auto validation</h2><p>While filling in some forms you&#8217;ll notice a little green check on the side. I can&#8217;t begin to praise how much faster this makes filling out forms. Directly after you&#8217;ve written enough letters in the password field you&#8217;ll find that it&#8217;s ok. No more trial and error against a slow server (unless you have javascript off, of course).</p><p><a
href="http://www.zapatec.com/website/ajax/zpform/doc/demo.html#ajax.html"><img
src="/files/ajaxexamples/autovalid.png" alt="Early notification that the password is correct"></a></p><h2>Controls affecting each other</h2><p>In complex forms it&#8217;s not unusual to want the user to fill in either one set of fields or another. The <a
href="http://www.quirksmode.org/js/disabled.html">showing and hiding</a> of what fields are available is a another perfect case of where javascript really helps.</p><h2>Image handling</h2><p>It&#8217;s time to get easy handling of images in browsers. Javascript can help there too, by combining drag and drop with resizing and so on. Photoshop, here we come!</p><p><a
href="http://www.walterzorn.com/dragdrop/dragdrop_e.htm"><img
src="/files/ajaxexamples/images.png" alt="Images you can move and resize in the browser"></a></p><h2>Search-based or structured navigation</h2><p>Sometimes new navigation schemes can be useful. Using search instead of navigation is an interesting idea. Another is letting the user pick categories and using them in search.</p><p><a
href="http://www.vitvarumaklarna.se/"><img
src="/files/ajaxexamples/searchstructure.png" alt="Menu that allows expanding and searching"></a></p><h2>Better <strong>looking</strong> form fields</h2><p>Javascript also allows you to enhance existing form fields with prettier equivalents.</p><p><a
href="http://www.ericd.net/styled_form/"><img
src="/files/ajaxexamples/checkboxes.png" alt="Pretty form controls"></a></p><h2>Sortable items</h2><p>Sometimes you want drag and drop in a more controllable manner. Why not use it to make it easier to sort your lists?</p><p><a
href="http://demo.script.aculo.us/ajax/sortable_elements"><img
src="/files/ajaxexamples/sortable.png" alt="Sortable list items"></a></p><p>That&#8217;s all! Hope I&#8217;ve given you some ideas of widgets/controls you can use to enhance user experience. Good luck!</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/js/improving-interactivity-with-javascript/feed/</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>Flash-only vs. AJAX sites</title><link>http://friendlybit.com/js/flash-only-vs-ajax-sites/</link> <comments>http://friendlybit.com/js/flash-only-vs-ajax-sites/#comments</comments> <pubDate>Mon, 15 Jan 2007 22:02:35 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/js/flash-only-vs-ajax-sites/</guid> <description><![CDATA[Even though web developers like me have discouraged from building Flash-only sites for as long as I remember, they are popping up all over the place. For no reason! We are ready to make the leap to standards. And our weapon with be AJAX.
What kind of sites are built with only Flash?
Let&#8217;s start by having [...]]]></description> <content:encoded><![CDATA[<p>Even though web developers like me have discouraged from building Flash-only sites for as long as I remember, they are popping up all over the place. For no reason! We are ready to make the leap to standards. And our weapon with be AJAX.</p><h2>What kind of sites are built with only Flash?</h2><p>Let&#8217;s start by having a look at a few big Flash sites. Because they exist, and keep popping up all over the place. Here&#8217;s a couple of movie sites using it: <a
href="http://thedeparted.warnerbros.com/">Departed</a>, <a
href="http://www.sonypictures.com/homevideo/underworldevolution/index.html">Underworld Evolution</a>, <a
href="http://whatisthematrix.warnerbros.com/">Matrix</a>; Here&#8217;s a couple of big brands: <a
href="http://www.coca-cola.se">Coca-cola</a>, <a
href="http://www.nike.com/">Nike</a>, <a
href="http://electrolux.com/">Electrolux</a>. These sites are more than just animated images, they have their own content and often need to get updated continuously.</p><h2>What&#8217;s the purpose of them?</h2><p>Before deciding on anything we need to examine what purpose these sites have. It&#8217;s not OK to change the purpose of the site just because we dislike the technology behind it. I can&#8217;t possibly know the reasons behind all of the campaigns going on today but I believe there&#8217;s a core that most sites are after.</p><ul><li><strong>Promote something new</strong> &#8211; Someone wants to to push some of their products/deals/ideas to the spotlight.</li><li><strong>Specific target audience</strong> &#8211; Companies are well aware that what kind of people they reach initially will define if the product is successful or not. Many want the hip people.</li></ul><h2>Updating flash files is hard</h2><p>Many years ago it was ok just to throw up static information on a site and have a good site. Don&#8217;t get me wrong, content is still king, what has changed is that content alone isn&#8217;t enough. We demand much more from a good website. Coca Cola can&#8217;t just publish a press release telling us that there is a new taste out. It&#8217;s the Web 2.0 age and we want to be able to send our own tasting stories in, we want to be able to see live counters of the number of bottles sold, and we want forums to talk amongst ourselves about our experiences. We want tags! You get the point.</p><p>How does this affect the choice of flash or not? We need dynamics, ways for both editors and users to add content to the site, and <strong>Flash files are hard to update</strong>! Just the fact that I need a special program to edit them speaks for itself.</p><p>Another fact: As you probably know, it&#8217;s rare (in the real world) to have the same person both writing code and publishing content. The coders need to cater for that, and make sure it&#8217;s easy for editors to add new content. Now. Even if you&#8217;ve bought licenses and are able to edit flash files, you can&#8217;t expect editors to understand all about how flash works. So you need to build a content management system (CMS) of some kind. If you buy one, you still need to integrate it with your current code.</p><p>&#8220;But&#8221;, I hear you say, &#8220;&#8230;you have that same problem with non-Flash sites!&#8221;. Yes, but the difference is that CMS tools that publish HTML have existed a lot longer. This affects both the quality, usability and ease of integration with current systems. A HTML-based site will therefore be easier to update, making for both more and fresher content that reaches more people. If it&#8217;s easy enough to update the site, you can even let users do it, Web 2.0 style.</p><h2>Flash is not hip any longer</h2><p>Publishing a site with Flash today is hardly going to get mentioned at all. AJAX has completely taken over the scene and anyone even <a
href="http://digg.com/programming/Flash_only_vs_AJAX_sites">whispering AJAX</a> gets to the front page of digg.</p><p>Aside from the technology buzz we have had some real changes rather recently: Javascript can now deliver what was once only available with Flash. It can fade, move, round corners, drag-drop, auto-save, validate, the list could go on forever&#8230; There&#8217;s several effect libraries available that makes using all those effects easity. All the good ones are even free.</p><h2>Flash-only vs. AJAX &#8211; The showdown</h2><p>I&#8217;ve made a small list of things that matters when you build a website today, and evaluated each one of them for both Flash-only and AJAX.</p><table><thead><tr><td></td><th
scope="col">Flash</th><th
scope="col">AJAX</th></tr></thead><tbody><tr><th
scope="row">Accessibility</th><td
class="incorrect"><strong>Poor</strong>. There&#8217;s problems with everything from how a flash app gets its initial focus from the browser window, to unusual interaction controls, to lack of text resize. In summary, zero points.</td><td
class="almost"><strong>Moderate</strong>. AJAX has problems with requiring js for accessing data, but smart developers have started thinking in terms of accessibility and fixed many of AJAX initial flaws. <a
href="http://www.robertnyman.com/2006/02/08/ask-ajax-source-kit">Nyman&#8217;s ASK</a> is one way.</td></tr><tr><th
scope="row">Search Engine Optimization (SEO)</th><td
class="incorrect"><strong>Poor</strong>. Search engines don&#8217;t read flash files (even though they probably could). Some people claim that you should <a
href="http://blog.deconcept.com/2006/03/13/modern-approach-flash-seo/">duplicate all your content</a>. I say that will be a mess to update.</td><td
class="almost"><strong>Moderate</strong>. If you just use the javascript effects you are fine, if you fetch data with javascript you need to write a little script that reloads the content and gets it that way instead. It is possible, but not easy enough. Bonus: if you fix accessibility you often get this too.</td></tr><tr><th
scope="row">Ease of content change</th><td
class="incorrect"><strong>Poor</strong>. You need an expensive program to edit the files. ? Only available on PCs running Windows. Few CMS:es available (any?) that makes it easy for editors to update content.</td><td
class="correct"><strong>Strong</strong>. All the big CMS:es can be used together with an AJAX app, it&#8217;s just a matter of changing the templates on the front. Systems like Ruby on Rails (while not being a CMS) have built in support for AJAX stuff, but including a framework in older systems is no big deal.</td></tr><tr><th
scope="row">Hipness</th><td
class="incorrect"><strong>Poor</strong>. There used to be a big community of flash developers that got incredible respect in the webdev community with their flash-only sites. Many of these communities have been replaced by CSS Galleries of different kinds.</td><td
class="correct"><strong>Strong</strong>. While Flash-only developers focused mainly on visuals the AJAX community have focused more on user experience, building applications that <em>feels</em> better to use. Together with the technology buzz behind it AJAX solutions have gotten (and still get) a great response from the start. The potential for marketing campaigns based on user experience in huge.</td></tr><tr><th
scope="row">Graphic effects</th><td
class="correct"><strong>Strong</strong>. This wouldn&#8217;t be a fair comparison if we didn&#8217;t acknowledge that Flash is far ahead of AJAX when it comes to graphic effects. Most of this is based in the fact that you are working in an application instead of a website, and things like anti-aliasing, drop shadows, transitions, and filters have existed for long.</td><td
class="almost"><strong>Moderate</strong>. Websites was long lacking pretty interfaces but in the recent years we&#8217;ve seen an explosion of graphic effects even in the standards world, probably starting with the famous <a
href="http://www.csszengarden.com/">CSS Zengarden</a>.</td></tr><tr><th
scope="row">Integration with existing sites</th><td
class="almost"><strong>Moderate</strong>. Few code libraries are written to work well together with flash, so often you have to do the integration yourself. In it&#8217;s latest version Flash has gotten more integration points with the possibility to communicate with javascript, import HTML and so on. Better, but not perfect.</td><td
class="correct"><strong>Strong</strong>. Most effect libraries are built to be as easy to include as possible. The usual way to make use of one is two lines long: link a javascript file and call the right function. The more advanced libraries that enable asynchronous loading require some more work, but unless you want advanced error handling it&#8217;s no big deal.</td></tr></tbody></table><p>Next time a customer ask for a Flash-only site, tell them about AJAX and it&#8217;s advantages.</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/js/flash-only-vs-ajax-sites/feed/</wfw:commentRss> <slash:comments>38</slash:comments> </item> <item><title>Web development blogs you should read</title><link>http://friendlybit.com/css/web-development-blogs-you-should-read/</link> <comments>http://friendlybit.com/css/web-development-blogs-you-should-read/#comments</comments> <pubDate>Sun, 19 Nov 2006 02:40:48 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/css/web-development-blogs-you-should-read/</guid> <description><![CDATA[The web is filled with blogs about web development. I&#8217;m always looking for good blogs to add to my feed reader and I thought some of you might do that too. So let me list the webdev blogs I subscribe to right now (in alphabetic order):456 Berea St &#8211; Roger Johansson is one of the [...]]]></description> <content:encoded><![CDATA[<p>The web is filled with blogs about web development. I&#8217;m always looking for good blogs to add to my feed reader and I thought some of you might do that too. So let me list the webdev blogs I subscribe to right now (in alphabetic order):</p><ul><li><strong><a
href="http://www.456bereastreet.com/">456 Berea St</a></strong> &#8211; Roger Johansson is one of the most well known web developers out there, and it&#8217;s for a reason. He posts almost daily about things happening in the webdev field. Everything from short comments with links to things to full blown articles.</li><li><strong><a
href="http://headrush.typepad.com/creating_passionate_users/">Creating passionate users</a></strong> &#8211; Simply one of the best blogs there is, all categories. Deals with usability and making users happy. The posts are everything from hilarious to spectacular and I often get the motivation to write from here. Read an article or just look at one of the wonderful graphs. You&#8217;ll love it.</li><li><strong><a
href="http://www.thefutureoftheweb.com/">Future of the web</a></strong> &#8211; Jesse Skinner writes for all skill levels. Articles vary from basic markup to advanced javascript tutorials. Often with a twist of humour added in the middle of an article. Nice read.</li><li><strong><a
href="http://mondaybynoon.com">Monday By Noon</a></strong> &#8211; Jon posts articles weekly (as reflected in the name) about all things related to web development. His friendly tone and ability to explain things makes this site ideal for people starting out. The good thing is that the same style works for more experienced people too. Try one of the articles, I&#8217;m sure you&#8217;ll like it.</li><li><strong><a
href="http://f6design.com/journal/">Pixel Acres</a></strong> &#8211; Jonathan Nicol combines webdev articles with thoughts on how to deal with clients and co-workers. Well written and qualitative, what else do you need?</li><li><strong><a
href="http://www.robertnyman.com/">Robert&#8217;s talk</a></strong> &#8211; Robert Nyman&#8217;s blog, mixing personal posts with those that have to do with all kinds of interfaces. Entertaining read that feels balanced and well thought-out.</li><li><strong><a
href="http://rundkvadrat.com/">Rund kvadrat</a></strong> &#8211; Blog in Swedish about making money on the web. While this isn&#8217;t the primary concern for many interface developers we should certainly keep it in mind. Does moving a certain link upwards increase the client&#8217;s sales?</li></ul><p>Well, and then there&#8217;s all the big ones, but they tend to post too much about the conferences they attended and the books they wrote. Also, all their good articles end up on the big webdev news sites, which I also subscribe to.</p><p>Do you have any other sites that should be on that list?</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/css/web-development-blogs-you-should-read/feed/</wfw:commentRss> <slash:comments>17</slash:comments> </item> <item><title>How web standards feels</title><link>http://friendlybit.com/css/how-web-standards-feels/</link> <comments>http://friendlybit.com/css/how-web-standards-feels/#comments</comments> <pubDate>Wed, 11 Oct 2006 19:34:42 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/css/how-web-standards-feels/</guid> <description><![CDATA[When talking about web standards many of us have started using marketing terms. Every day we hear about the bandwidth savings, the increased user base that are able to access your site, how well it affects SEO and so on. But none of that was what got me into all this. Let me tell you [...]]]></description> <content:encoded><![CDATA[<p>When talking about web standards many of us have started using marketing terms. Every day we hear about the bandwidth savings, the increased user base that are able to access your site, how well it affects SEO and so on. But none of that was what got me into all this. Let me tell you about the thing that convinced me: the feeling.</p><p>For me the web standards revolution started with a feeling that something was wrong. &#8220;There has got to be a better way&#8221;, was a thought that buzzed in my ears when nesting my tables to create some padding.</p><p>I first saw CSS in other people&#8217;s code, often embedded in style attributes with text-decoration: none; to remove underlines. I started experimenting, but the deeper aspects of how it could change the way websites were built didn&#8217;t occur to me. It was just another tool to place things where I wanted them, and make things look like I wanted.</p><p>At that time I didn&#8217;t know any server-side language so all my sites where frame based static HTML, often with a fancy javascript enabled select box for navigation. I did use some CSS just to remove the underlinings on my links, but that was it. Something still felt wrong, was this really the best way?</p><p>The &#8220;AHA!&#8221; feeling came much later; I&#8217;d love to say a certain moment when I understood but it wasn&#8217;t a certain text or piece of advice, it grew on me. Suddenly everything felt like it had its place. It wasn&#8217;t always obvious where that place was, but you could reason your way there. When the strength of CSS occurred to me, it was like finally understanding a tough mathematical formula. Yes!</p><p>So go ahead, show me your pretty charts of workday savings, <a
href="http://csszengarden.com/">CSS Zen garden</a> remakes, or new techniques you can use. I like them, I really do, but I&#8217;m pretty convinced it&#8217;s the &#8220;AHA!&#8221; feeling that finally wins people over to the web standards side.</p><p>What won you over? Can you convince someone else using that method?</p><p>(Inspiration from <a
href="http://headrush.typepad.com/creating_passionate_users/2006/09/motivating_othe.html">Motivating others</a>)</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/css/how-web-standards-feels/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Concept: Four layers of web development</title><link>http://friendlybit.com/css/concept-four-tier-web-development/</link> <comments>http://friendlybit.com/css/concept-four-tier-web-development/#comments</comments> <pubDate>Sat, 03 Jun 2006 16:45:07 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[JS]]></category> <category><![CDATA[Tutor]]></category><guid
isPermaLink="false">http://friendlybit.com/css/concept-four-tier-web-development/</guid> <description><![CDATA[When thinking about web development on the client side, I tend to think of four different layers. Any (well built) framework will cater for all of these layers and all good developers will be aware of them. The layers I&#8217;m thinking about are: Data, Structure, Design, and Behavior. This article discusses all four of those [...]]]></description> <content:encoded><![CDATA[<p>When thinking about web development on the client side, I tend to think of four different layers. Any (well built) framework will cater for all of these layers and all good developers will be aware of them. The layers I&#8217;m thinking about are: Data, Structure, Design, and Behavior. This article discusses all four of those and explains how they relate.</p><h2>Data layer</h2><p>The data layer is the most important one and strangely the one most people get confused about. HTML is <em>not</em> the data layer, the <strong>content</strong> is. The data layer is the raw data that you are presenting, the text, the images, the sound, the video, whatever content you want to serve. For bigger sites the data is often stored in a database or perhaps XML files somewhere and then processed server side every time someone wants to access it.</p><p>This layer is also where all websites should start. What content do you have? If the content is bad no pretty design or fancy Web 2.0 technique is going to cater for that. In fact, content together with bad uses of the other layers, <a
href="http://www.andyrutledge.com/bad-design.php">might still work</a>!</p><p>One last point to make about data is that you should make sure to use the best possible media for representing your content. If it can be text, use text! Don&#8217;t use images for text, narrate your podcasts (or at least provide a text-summary), put your videos online with descriptions to them. Having that text there helps you convey your point, search engines will find you, your users will be able to skim read while it loads and disabled users will get access to at least some of your content.</p><h2>Structural layer</h2><p>The structural layer is where the much misunderstood HTML comes to play. HTML&#8217;s job is to take the data it has received from the data layer and <a
href="http://friendlybit.com/html/datatypes-of-html/" title="Some examples of data structures you have available in HTML">add some structure to it</a>. Mark up what parts are headers, make sure lists get the HTML that best describes them, split the page up in the important parts and so on.</p><p>HTML also adds some semantics to the data but since it&#8217;s quite a limited dictionary we have to work with I believe this is secondary. If you happened to have the kind of data that HTML happens to catch with its elements be sure to use them, if not make sure you at least capture the structure of it.</p><p>You know you have done this level right if your site works with nothing but data and structure.</p><h2>Design layer</h2><p>The design layer is where you define the looks of your data. Design requires a good basic structure to be useful. On the web you should use CSS for this layer, a language that has been built upon the idea of a solid structure and is remarkably powerful. As you know CSS targets certain elements and then defines their look. Without a solid structure this is not possible.</p><p>Good designers often point out that only working with the looks of a site will not accomplish good design. They also work on the structural layer by making sure structurally important content gets the most exposure in the design. This is also strengthens the idea that structure is a layer upon which design works.</p><h2>Behavioral layer</h2><p>Behavior is the last layer I&#8217;m going to talk about. It&#8217;s the one that&#8217;s least important; data, structure and design are all more effective in conveying your message. None the less, added behavioral functionality <em>can</em> be powerful if executed properly on top of the other layers.</p><p>Javascript is the most used language for adding new behavior to websites. With the whole <a
href="http://en.wikipedia.org/wiki/Web_2.0">Web 2.0</a> and <a
href="http://en.wikipedia.org/wiki/Ajax_%28programming%29">AJAX</a> wave we are experiencing many new sites that adds a behavioral layer without even thinking about it. We should be careful; becoming dependent on the new behavior (the site not working without it) means you will lose many potential visitors, the most important single one being search engines. Behavior should always be added separately and only enhance the experience for those that has it enabled. This is what&#8217;s called <a
href="http://adactio.com/atmedia2005/" title="Jeremy Keith presents the idea of unobtrusive javascript">unobtrusive javascript</a>.</p><h2>Putting it all together: four tier web development</h2><p>Putting all these four parts together we get the following:</p><p><img
src="/files/four-tier-webdev.png" alt="Adding layers step by step to a paragraph of text"></p><p>Is this the same mental model you use? Let me know through comments.</p><p>[<strong>Update:</strong> Threehouse has an image up <a
href="http://treehousemagazine.com/images/screenshots/4screen2.jpg">showing the four layers</a> in the context of javascript connection the layers together.]</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/css/concept-four-tier-web-development/feed/</wfw:commentRss> <slash:comments>17</slash:comments> </item> <item><title>Challenge: What&#8217;s the worst you can do?</title><link>http://friendlybit.com/css/challange-whats-the-worst-you-can-do/</link> <comments>http://friendlybit.com/css/challange-whats-the-worst-you-can-do/#comments</comments> <pubDate>Sat, 11 Mar 2006 15:09:26 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/css/challange-whats-the-worst-you-can-do/</guid> <description><![CDATA[After reading through the comments on my levels of CSS article I find that I few people seem to think that the article is a way to ridicule beginners. It&#8217;s not. It&#8217;s a way to document the steps that I think I have climbed. Some people also thought that this set of levels is a [...]]]></description> <content:encoded><![CDATA[<p>After reading through the comments on my <a
href="http://friendlybit.com/css/levels-of-css-knowledge/">levels of CSS</a> article I find that I few people seem to think that the article is a way to ridicule beginners. It&#8217;s not. It&#8217;s a way to document the steps that I think I have climbed. Some people also thought that this set of levels is a good indicator of how good sites you will make. That&#8217;s also false. Being Level 5 or 6 in the list means that you are a good <em>coder</em>, nothing else. It does not mean that a site you make is any good, I&#8217;ve seen many sites that have great code but that still makes me want to kill someone. Don&#8217;t confuse good web developers with good coders. &#8220;Don&#8217;t be a <a
href="http://www.molly.com/2006/02/23/how-to-sniff-out-a-rotten-standardista/">rotten standardista</a>&#8221; as Molly Holzschlag would put it.</p><h2>The challenge</h2><p>To give you a perspective of how bad it really could be I&#8217;m challenging all the readers of Friendly Bit. It&#8217;s kind of a competition (with no prize) about who can make the worst site. The rules are simple; you are to construct a page, using HTML and CSS (and Javascript if you think you need it) that has a design that is as hideous as possible. I want pages that make my eyes bleed, that make small children cry and makes <a
href="http://maddox.xmission.com/">Maddox</a> write hate articles about you. Think of all the good things you&#8217;ve learnt and do the opposite.</p><h2>Inspiration for a truly hideous design</h2><p>I won&#8217;t be giving out any prize but what I can do is help you with some ideas of bad code.</p><p>Make use of the <code >&lt;marquee&gt;</code> tag. It makes any content inside it scroll in the speed and direction you choose. Did you know that you can wrap <code >&lt;body&gt;</code> in a marquee tag? That&#8217;s right, your entire page will move automatically. You can also nest several marquee tags inside each other. Ohh yeah!</p><p>Another good tag you can use is the <code >&lt;blink&gt;</code> tag. Can it be applied to, say, a table? I hear you ask. But of course. You can have a full screen blinking table on your company homepage.</p><p>Continuing with the good ideas we have the oldschool <em>frames</em> we all have come to like. Did you know that there are no set upper limit on the number of frames you can load? You can have thousands of them! You can even mark up a whole tabular grid with frames alone.</p><p>This challange is about <em>terrible code</em> as much as it&#8217;s about terrible design. So don&#8217;t go with well-formed or the basic foundations of HTML. Did you even try putting tags inside other tags? <code >&lt;font &lt;font size="2"&gt; size="3"&gt;</code> is quite fantastic don&#8217;t you think? Make your page upside down by adding the <code >&lt;head&gt;</code> below the <code >&lt;body&gt;</code>, but only after you have added your own <code >&lt;neck&gt;</code> tag to the mix. Surprise me!</p><h2>How to accept the challenge</h2><p>To join all of this you just have to make the page, put it up on your server and link to it here. Post a link as a comment or simply trackback (link to this post) from your own blog and it will show up here.</p><p>Finally: Don&#8217;t forget the lesson behind all this. When you see a site with bad code, know that there&#8217;s a lot of much worse sites out there.</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/css/challange-whats-the-worst-you-can-do/feed/</wfw:commentRss> <slash:comments>35</slash:comments> </item> <item><title>Extra fluid layouts with javascript</title><link>http://friendlybit.com/css/extra-fluid-layouts-with-javascript/</link> <comments>http://friendlybit.com/css/extra-fluid-layouts-with-javascript/#comments</comments> <pubDate>Mon, 13 Feb 2006 00:00:31 +0000</pubDate> <dc:creator>Emil Stenström</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[JS]]></category><guid
isPermaLink="false">http://friendlybit.com/css/extra-fluid-layouts-with-javascript/</guid> <description><![CDATA[I&#8217;m a big fan of vector graphics. Because of that I love Macromedia Fireworks and the way it handles all elements like vectors. The good thing about that is that they can be resized and zoomed without them losing their sharpness.
This got me thinking about how to add some vectorization to CSS layouts. My [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;m a big fan of vector graphics. Because of that I love Macromedia Fireworks and the way it handles all elements like vectors. The good thing about that is that they can be resized and zoomed without them losing their sharpness.</p><p>This got me thinking about how to add some vectorization to CSS layouts. My idea was that you should let the width of the screen decide the font-size of, for example, your headers. This could make for nice fluid layouts and might even add to usability in some cases. There are probably other uses for this but I leave that to you, please use the comments if you come up with something.</p><p>Start by having a look at the <a
href="/files/window_fontsize/">dynamic font-size example</a> just so we&#8217;re talking about the same thing. Try resizing the window and reloading and see that the headers really do adapt to the width of the browser window.</p><h2>How it&#8217;s done</h2><p>First we need a way to meassure the width of the text in the default font. For this I use my own little getTextWidth() that were constructed in my <a
href="/css/line-breaking-with-javascript/">line-break script</a>. It simply takes a piece of text, attaches it to the page, meassures it&#8217;s width and removes it again.</p><pre><code >function getTextWidth(text) {
   var ea = document.createElement("span");
   ea.innerHTML = text;
   document.body.appendChild(ea);
   var len = ea.offsetWidth;
   document.body.removeChild(ea);
   return len;
}</code></pre><p>Ok, now we know the width of some text in it&#8217;s non formated state. Next up is to scale it as much as needed.</p><pre><code >function scaleUp(elem, targetWidth) {
   var blockWidth = getTextWidth(elem.innerHTML);
   var defaultSize = parseInt(elem.style.fontSize || '100%')
   var newSize = Math.floor(0.9*targetWidth/(blockWidth/defaultSize))
   elem.style.fontSize = newSize + "%";
}</code></pre><p>As you see scaleUp() determines a percentage by looking at three things: it&#8217;s unformated width, it&#8217;s current width and the target width. Font-size and text width does not seem to follow eachother perfectly so an additional multiplication by 0.9 is needed.</p><p>This handy little function is then called with the element you want to scale and the width in pixels of how wide you want it. The calls look something like this:</p><pre><code >var element = document.getElementsByTagName("h1")[0];
var width = document.body.offsetWidth;
scaleUp(element, width);</code></pre><p>That&#8217;s it, hope you find some fun use for it.</p><p>[<strong>Update:</strong> After doing some research I see that Eric Meyer is already using something like this in his <a
href="http://www.meyerweb.com/eric/tools/s5/">slideshow system S5</a>. Well well, it was a funny exercise none the less.]</p> ]]></content:encoded> <wfw:commentRss>http://friendlybit.com/css/extra-fluid-layouts-with-javascript/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> </channel> </rss>
<!-- This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 5/10 queries in 0.016 seconds using disk

Served from: c8.67.364a.static.theplanet.com @ 2010-03-15 13:01:03 -->