<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3698186131165328823</id><updated>2012-02-16T02:57:16.534-08:00</updated><category term='first-child'/><category term='jquery'/><category term='iframes'/><category term='last-child'/><category term='IE'/><category term='unicode'/><category term='jqueryui'/><category term='IntelliJ'/><category term='dropshadows'/><category term='css'/><category term='IDE'/><category term='Javascript'/><title type='text'>Building on Mud</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://buildingonmud.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://buildingonmud.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ben Lisbakken</name><uri>http://www.blogger.com/profile/07310171879372717926</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3698186131165328823.post-8379943837000252513</id><published>2011-02-10T13:58:00.000-08:00</published><updated>2011-02-10T15:16:18.100-08:00</updated><title type='text'>No doctype and window.name</title><content type='html'>No doctype in an HTML doc forces quirksmode.  This makes IE behave like IE5.  I couldn't figure out why this didn't work:&lt;br /&gt;Parent frame:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;script&amp;gt;&lt;br /&gt;var iframe = document.createElement('iframe');&lt;br /&gt;iframe.name = 'no_worky';&lt;br /&gt;iframe.src = 'childframe.html';&lt;br /&gt;document.body.appendChild(iframe);&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;childframe.html:&lt;br /&gt;&amp;lt;script&amp;gt;&lt;br /&gt;alert(window.name);&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;That will alert nothing in IE!  Wow, this took a long time to find.  Fixing it was just a matter of tricking it a bit.  All you need to do is set the name on the contentWindow after appending the child:&lt;br /&gt;Parent frame:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;script&amp;gt;&lt;br /&gt;var iframe = document.createElement('iframe');&lt;br /&gt;iframe.src = 'childframe.html';&lt;br /&gt;document.body.appendChild(iframe);&lt;br /&gt;&lt;b&gt;iframe.contentWindow.name = 'worky';&lt;/b&gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Also, make sure that the &lt;code&gt;iframe.contentWindow.name&lt;/code&gt; comes After the &lt;code&gt;iframe.src&lt;/code&gt; is set&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3698186131165328823-8379943837000252513?l=buildingonmud.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildingonmud.blogspot.com/feeds/8379943837000252513/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3698186131165328823&amp;postID=8379943837000252513' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/8379943837000252513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/8379943837000252513'/><link rel='alternate' type='text/html' href='http://buildingonmud.blogspot.com/2011/02/no-doctype-and-windowname.html' title='No doctype and window.name'/><author><name>Ben Lisbakken</name><uri>http://www.blogger.com/profile/07310171879372717926</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3698186131165328823.post-6403452405486803478</id><published>2011-01-21T09:35:00.000-08:00</published><updated>2011-01-21T09:41:06.918-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='first-child'/><category scheme='http://www.blogger.com/atom/ns#' term='last-child'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>first-child last-child and negative margin fixes for IE</title><content type='html'>Want to use the CSS selectors first-child or last-child but are having compatibility problems?&lt;br /&gt;first-child is supported by current version browsers as of this post, including IE8.&lt;br /&gt;last-child is also supported by current version browsers, excluding IE8.&lt;br /&gt;&lt;br /&gt;For backward compatibility with IE to mimic first and last child, try:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;!--[if lt IE 8]&amp;gt;&lt;br /&gt;&amp;lt;style type="text/css"&amp;gt;&lt;br /&gt;.className {&lt;br /&gt;  margin-bottom: expression(this.nextSibling==null?'0px':'12px');&lt;br /&gt;}&lt;br /&gt;&amp;lt;/style&amp;gt;&lt;br /&gt;&amp;lt;![endif]--&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;You can swap previousSibling with nextSibling.&lt;br /&gt;&lt;br /&gt;Another note: IE6 and 7 do not allow negative margins.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3698186131165328823-6403452405486803478?l=buildingonmud.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildingonmud.blogspot.com/feeds/6403452405486803478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3698186131165328823&amp;postID=6403452405486803478' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/6403452405486803478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/6403452405486803478'/><link rel='alternate' type='text/html' href='http://buildingonmud.blogspot.com/2011/01/first-child-last-child-and-negative.html' title='first-child last-child and negative margin fixes for IE'/><author><name>Ben Lisbakken</name><uri>http://www.blogger.com/profile/07310171879372717926</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3698186131165328823.post-4892682420199025896</id><published>2010-06-02T15:34:00.000-07:00</published><updated>2010-06-02T15:44:02.440-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='IE'/><category scheme='http://www.blogger.com/atom/ns#' term='iframes'/><title type='text'>IE iFrame refresh and back button problem</title><content type='html'>Have you ever noticed that in all IE's, when you refresh a page (or click the back button) the iFrames are automatically populated?  This can be a problem if you are trying to pass unique args into the iFrames.&lt;br /&gt;&lt;br /&gt;Here's a short example.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;parent.html&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;  &amp;lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&amp;gt;&lt;br /&gt;  &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;  &amp;lt;div id="content"&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;  &amp;lt;script type="text/javascript" charset="utf-8"&amp;gt;&lt;br /&gt;  var iFrame = document.createElement('iframe');&lt;br /&gt;  var random = Math.random() * 1000;&lt;br /&gt;  iFrame.name = random;&lt;br /&gt;  iFrame.id = random;&lt;br /&gt;  iFrame.src = 'http://path/to/child.html?r=' + random;&lt;br /&gt;  document.getElementById('content').appendChild(iFrame);&lt;br /&gt;  &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;child.html&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;  &amp;lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&amp;gt;&lt;br /&gt;  &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;  &amp;lt;script type="text/javascript" charset="utf-8"&amp;gt;&lt;br /&gt;  alert(window.location.search);&lt;br /&gt;  &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;When you go to parent.html then child.html will alert the random number that was put into it's SRC.  When you refresh the page, it will alert the same number!  This is because IE does some funky things with browser history.  In this case, it thinks it's saving you some trouble by repopulating the exact iFrame that was there before.  Really, it's causing a whole lot of trouble!&lt;br /&gt;&lt;br /&gt;To trick it, use this&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;parent.html&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;  &amp;lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&amp;gt;&lt;br /&gt;  &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;  &amp;lt;div id="content"&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;  &amp;lt;script type="text/javascript" charset="utf-8"&amp;gt;&lt;br /&gt;  var iFrame = document.createElement('iframe');&lt;br /&gt;  var random = Math.random() * 1000;&lt;br /&gt;  iFrame.name = random;&lt;br /&gt;  iFrame.id = random;&lt;br /&gt;  iFrame.style.display = 'none';&lt;br /&gt;  document.getElementById('content').appendChild(iFrame);&lt;br /&gt;  iFrame.src = 'http://path/to/child.html?r=' + random;&lt;br /&gt;  iFrame.style.display = '';&lt;br /&gt;  &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;By not giving the iFrame a src and having it hidden when it's appended, IE will not try to populate it with what it has in the history.  Then, immediately after we append it, we can set the src to what we want and display it!&lt;br /&gt;&lt;br /&gt;Magic!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3698186131165328823-4892682420199025896?l=buildingonmud.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildingonmud.blogspot.com/feeds/4892682420199025896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3698186131165328823&amp;postID=4892682420199025896' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/4892682420199025896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/4892682420199025896'/><link rel='alternate' type='text/html' href='http://buildingonmud.blogspot.com/2010/06/ie-iframe-refresh-and-back-button.html' title='IE iFrame refresh and back button problem'/><author><name>Ben Lisbakken</name><uri>http://www.blogger.com/profile/07310171879372717926</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3698186131165328823.post-4339435735684309164</id><published>2009-06-19T14:03:00.000-07:00</published><updated>2009-06-19T14:06:07.906-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='unicode'/><title type='text'>Convert a String to Unicode in Javascript</title><content type='html'>I had to do some searching to figure out how to turn strings into unicode in Javascript.  In the end, I had to piece multiple different explanations together, and write my own function.  Here's that function:&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;function toUnicode(theString) {&lt;br /&gt;  var unicodeString = '';&lt;br /&gt;  for (var i=0; i &lt; theString.length; i++) {&lt;br /&gt;    var theUnicode = theString.charCodeAt(i).toString(16).toUpperCase();&lt;br /&gt;    while (theUnicode.length &lt; 4) {&lt;br /&gt;      theUnicode = '0' + theUnicode;&lt;br /&gt;    }&lt;br /&gt;    theUnicode = '\\u' + theUnicode;&lt;br /&gt;    unicodeString += theUnicode;&lt;br /&gt;  }&lt;br /&gt;  return unicodeString;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;It will output a string in the form '\uXXXX'.  Take that and put it in your Javascript as a string, and it will convert it to the correct character for you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3698186131165328823-4339435735684309164?l=buildingonmud.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildingonmud.blogspot.com/feeds/4339435735684309164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3698186131165328823&amp;postID=4339435735684309164' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/4339435735684309164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/4339435735684309164'/><link rel='alternate' type='text/html' href='http://buildingonmud.blogspot.com/2009/06/convert-string-to-unicode-in-javascript.html' title='Convert a String to Unicode in Javascript'/><author><name>Ben Lisbakken</name><uri>http://www.blogger.com/profile/07310171879372717926</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3698186131165328823.post-4984118026646185403</id><published>2008-12-09T20:07:00.000-08:00</published><updated>2009-10-15T13:29:36.347-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IDE'/><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='IntelliJ'/><title type='text'>New Favorite Javascript Editor</title><content type='html'>I love TextMate. I started using TextMate a few years ago when it was proclaimed as the "best" editor in the Ruby on Rails community. Long since I stopped writing RoR, I'm still using TextMate for HTML, CSS and Javascript. It's got great snippets, hot themes, I like the indenting, it's very light-weight, it's got great tag matching and people write cool plugins/scripts for it. There are definitely 1,001 things I like about it. &lt;br /&gt;&lt;br /&gt;But as I have been writing a lot of code each day for a few months now, I have begun to realize how many of my errors are caused by misspellings (p.s. I just had to spell-correct that) and stupid forgetfulness. I can't even tell you how many times 'I've' renamed a function and had to go digging around the code for 5-10 minutes to see what else needs to be changed. I would say that around 70% or more of my errors are stupid errors. This sucks. I shouldn't be wasting my time because I don't type perfectly, or because I don't have all of my variable names memorized, or even because I forget that I'm working with an object, not an array, so I can't for (i=0; i&amp;lt;object.length; i++) through it.&lt;br /&gt;&lt;br /&gt;What I wanted was code completion with introspection and an as-I-type error checker that is more powerful than JSLint. See, JSLint only checks for boring syntax errors. It checks for the things that are the 30-second-to-fix-Firebug-found-it-immediately-anyways errors. And since Firebug is just as good as JSLint then why bother with JSLint?&lt;br /&gt;&lt;br /&gt;I wanted error checking for the gotcha's, the things like:&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;document.write("&amp;lt;script&amp;gt;alert('hi');&amp;lt;/script&amp;gt;");&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;In that code, the &amp;lt;/script&amp;gt; in the document.write should be &amp;lt;\/script&amp;gt;, otherwise it will escape the parent &amp;lt;script&amp;gt; tag. I want something that will check for unused functions/variables, deprecated Javascript, using a reserved word as a name. I wanted a real IDE for Javascript.&lt;br /&gt;&lt;br /&gt;I played around with 4 IDE's that I thought would be good for Javascript: Komodo Edit/IDE, Eclipse, IntelliJ and Aptana. Hands down IntelliJ is the best. It had practically everything I wanted.&lt;br /&gt;&lt;br /&gt;My Love for IntelliJ is as follows: &lt;ul&gt;&lt;li&gt;Introspection for auto-complete. IntelliJ not only knows that &amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt; has a method &amp;lt;code&amp;gt;write&amp;lt;/code&amp;gt;, it also knows that up above you have a variable named &amp;lt;code&amp;gt;myVar&amp;lt;/code&amp;gt; and an object with 6 prototype methods. And when you try to use them it autocompletes for you. But what's more is that it checks your script includes and autocompletes those for you. So if I am in a.html and I'm writing in a script block, if I am typing a method for object &amp;lt;code&amp;gt;myObj&amp;lt;/code&amp;gt; then it will auto-complete that for me.&lt;/li&gt;&lt;li&gt;Error checking. IntelliJ yells at me every time I misplace those semi-colons and commas. This saves me from having to waste my time refreshing my code in the browser.&lt;/li&gt;&lt;li&gt;Easy refactoring of method/variable names.&lt;/li&gt;&lt;li&gt;Auto-cleans up extra white spaces.&lt;/li&gt;&lt;li&gt;Millions of options. Literally everything is configurable. There is a search box Just For The Preferences&lt;/li&gt;&lt;li&gt;You can debug Javascript just like with Firebug, without having to switch to your browser. Breakpoints included.&lt;/li&gt;&lt;li&gt;Easy finding of definition/use of objects. If I want to see where a method is defined, it's just one click away.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;So go download the free trial and try it out for yourself. It's really the best.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3698186131165328823-4984118026646185403?l=buildingonmud.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildingonmud.blogspot.com/feeds/4984118026646185403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3698186131165328823&amp;postID=4984118026646185403' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/4984118026646185403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/4984118026646185403'/><link rel='alternate' type='text/html' href='http://buildingonmud.blogspot.com/2008/12/new-favorite-javascript-editor.html' title='New Favorite Javascript Editor'/><author><name>Ben Lisbakken</name><uri>http://www.blogger.com/profile/07310171879372717926</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3698186131165328823.post-8747553592408305492</id><published>2008-10-24T10:35:00.000-07:00</published><updated>2008-10-30T15:02:16.952-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jquery'/><category scheme='http://www.blogger.com/atom/ns#' term='jqueryui'/><category scheme='http://www.blogger.com/atom/ns#' term='dropshadows'/><title type='text'>Drop shadow on any div, scalable</title><content type='html'>Drop shadows are undeniably cool.  It really brings a new element to a page.  I generally suck at UI and when I was talking to someone about making UI, one interesting thing he said was: "Make the page feel 3D.  Design your page so that you can imaging closing your eyes, running your fingers over it and being able to feel the different buttons and layers."&lt;br /&gt;&lt;br /&gt;Since I have no eye for design, this was a really interesting idea to me -- I had never thought about the look of the layers.  Drop shadows and gradients can really help with this.  But just don't go overboard on them.&lt;br /&gt;&lt;br /&gt;Anyways, I had a draggable and resizable div (thanks, jQuery UI!) and I wanted to put a drop shadow on it so that you can tell that it is lifted off the page and is meant to be moved around.  It turns out doing this isn't straightforward like is should be.  There were a few approaches I took at first that failed (hey, I wanted to try all of the shortcuts first).&lt;br /&gt;&lt;br /&gt;First I tried having one image that was slightly bigger than my div.  It would have the blurred edges and I would simply put it behind my div and position it appropriately.  When I moved/resized my div, I do the same for my image.  The problem here is that when you scale up/down the image then the width/density of the blur (which causes the shadow) changes.  So a huge div with my image background has a really wide shadow, and a small div would have a tiny shadow.  That made it seem like the bigger the div got, the more it popped out at me.&lt;br /&gt;&lt;br /&gt;The next thing I tried was to just have the drop shadow on the bottom and right of the div.  I was going to create one image for the bottom, and one image for the right.  That way when I scaled the div's height, the right div's height would expand and it wouldn't distort the width of the shadow as well (like in my previous attempt).  This failed, too, because as you scale the divs their density of pixels still changes, and makes them look goofy when they are extreme sizes.&lt;br /&gt;&lt;br /&gt;The approach I totally tried to avoid and had to end up settling for was 5 images.  A bottom left, 1px wide bottom, bottom right, 1px right side and a top right image.  I just really, really didn't want to create all of these images.  Admittedly, I'm terrible with Photoshop (there are too many buttons!).  I used GIMP and it wasn't too painful.  This approach made it it so that I never had to scale the corner images so they would never distort.  Then, with the 1px repeating images as the backgrounds for the bottom middle and right middle divs, I could just scale those divs and have my whole drop shadow scale nicely without distortion.&lt;br /&gt;&lt;br /&gt;Talk is cheap though, so here's how I did it:&lt;br /&gt;1) Create your drop shadow image.  I didn't realize how easy this was until I tried it.  Just draw the shape you want a drop shadow for (aka a square, or a square with rounded corners) on top of a transparent background, fill it in black, then find the filter tool on your favorite image editor and start blurring your image.  I used a 10px by 10px blur 5 times in a row.&lt;br /&gt;&lt;br /&gt;2) Start cropping your individual images.  Cut out the upper right corner, cut out a 1px segment of the right side that's the same width as the upper right etc. etc.  Take a look at my &lt;a href="http://4.bp.blogspot.com/_SMX3B8kFlhU/SQocMYR-qYI/AAAAAAAAACw/B54vfV-Ad80/s1600-h/bl.png"&gt;bottom left&lt;/a&gt;, &lt;a href="http://4.bp.blogspot.com/_SMX3B8kFlhU/SQob4aaasSI/AAAAAAAAACo/Cpw5zmxfTag/s1600-h/b1px.png"&gt;bottom middle&lt;/a&gt;, &lt;a href="http://3.bp.blogspot.com/_SMX3B8kFlhU/SQocMpE49hI/AAAAAAAAAC4/BE3OPmfSAsI/s1600-h/br.png"&gt;bottom right&lt;/a&gt;, &lt;a href="http://1.bp.blogspot.com/_SMX3B8kFlhU/SQocMyqBu6I/AAAAAAAAADA/dOc276woRl0/s1600-h/r1px.png"&gt;middle right&lt;/a&gt;, &lt;a href="http://4.bp.blogspot.com/_SMX3B8kFlhU/SQocNtrNAnI/AAAAAAAAADI/CFsAjxDdANQ/s1600-h/tr.png"&gt;upper right&lt;/a&gt; pieces.&lt;br /&gt;&lt;br /&gt;3) Setup your CSS &amp; HTML.  Lay down your content div, put your shadow div under it and put the image divs in.  Fiddle with some CSS and whammo, you can move your shadow div to the same coordinates as the content div and it will always have a drop shadow.  My code:&lt;br /&gt;&lt;pre class="code" style="height: 300px; overflow: auto;" &gt;&amp;lt;head&amp;gt;&lt;br /&gt;  &amp;lt;title&amp;gt;Drop Shadow Maddness&amp;lt;/title&amp;gt;&lt;br /&gt;  &amp;lt;style type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot;&amp;gt;&lt;br /&gt;    #shadowContainer {&lt;br /&gt;      width: 500px;&lt;br /&gt;      height: 500px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      top: 10px;&lt;br /&gt;      left: 10px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .brShadow {&lt;br /&gt;      background: url(imgs/br.png) no-repeat;&lt;br /&gt;      width: 58px;&lt;br /&gt;      height: 50px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      right: -17px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .bottomShadows {&lt;br /&gt;      top: 467px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .rightShadows {&lt;br /&gt;      right: -17px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .blShadow {&lt;br /&gt;      background: url(imgs/bl.png) no-repeat;&lt;br /&gt;      width: 45px;&lt;br /&gt;      height: 51px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      left: 0px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .bShadow {&lt;br /&gt;      background: url(imgs/b1px.png) repeat;&lt;br /&gt;      height: 51px;&lt;br /&gt;      width: 414px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      right: 41px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .trShadow {&lt;br /&gt;      background: url(imgs/tr.png) no-repeat;&lt;br /&gt;      width: 58px;&lt;br /&gt;      height: 51px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      right: -17px;&lt;br /&gt;      top: 0px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .rShadow {&lt;br /&gt;      background: url(imgs/r1px.png) repeat;&lt;br /&gt;      height: 416px;&lt;br /&gt;      width: 58px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      right: -17px;&lt;br /&gt;      top: 51px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    #topDiv {&lt;br /&gt;      position:absolute;&lt;br /&gt;      background-color:white;&lt;br /&gt;      left: 10px;&lt;br /&gt;      top: 10px;&lt;br /&gt;      width: 500px;&lt;br /&gt;      height: 500px;&lt;br /&gt;      border: 1px solid #999;&lt;br /&gt;    }&lt;br /&gt;  &amp;lt;/style&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;  &amp;lt;div id=&amp;quot;shadowContainer&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;div class=&amp;quot;blShadow bottomShadows&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;div class=&amp;quot;bShadow bottomShadows&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;div class=&amp;quot;brShadow bottomShadows rightShadows&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;div class=&amp;quot;rShadow rightShadows&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;div class=&amp;quot;trShadow rightShadows&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;/div&amp;gt;&lt;br /&gt;  &amp;lt;div id=&amp;quot;topDiv&amp;quot;&amp;gt;This is my awesome DIV&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;4) OK if you have a static sized div you are done.  If you want your div to move around, and the drop-shadow with it, you're going to have to add some more CSS, or setup some event handlers to change the size.  Check out my code with jQuery UI so that the div is resizable:&lt;br /&gt;&lt;pre class="code" style="height:300px; overflow:auto"&gt;&amp;lt;head&amp;gt;&lt;br /&gt;  &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;  &amp;lt;script src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;script src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.2/jquery-ui.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;  &amp;lt;style type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;    #shadowContainer {&lt;br /&gt;      width: 500px;&lt;br /&gt;      height: 500px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      top:0px;&lt;br /&gt;      left:0px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .brShadow {&lt;br /&gt;      background: url(imgs/br.png) no-repeat;&lt;br /&gt;      width: 58px;&lt;br /&gt;      height: 50px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      right: -17px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .bottomShadows {&lt;br /&gt;      top: 467px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .rightShadows {&lt;br /&gt;      right: -17px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .blShadow {&lt;br /&gt;      background: url(imgs/bl.png) no-repeat;&lt;br /&gt;      width: 45px;&lt;br /&gt;      height: 51px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      left: 0px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .bShadow {&lt;br /&gt;      background: url(imgs/b1px.png) repeat;&lt;br /&gt;      height: 51px;&lt;br /&gt;      width: 414px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      right: 41px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .trShadow {&lt;br /&gt;      background: url(imgs/tr.png) no-repeat;&lt;br /&gt;      width: 58px;&lt;br /&gt;      height: 51px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      right: -17px;&lt;br /&gt;      top: 0px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .rShadow {&lt;br /&gt;      background: url(imgs/r1px.png) repeat;&lt;br /&gt;      height: 416px;&lt;br /&gt;      width: 58px;&lt;br /&gt;      position: absolute;&lt;br /&gt;      right: -17px;&lt;br /&gt;      top: 51px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    #topDiv {&lt;br /&gt;      position:absolute;&lt;br /&gt;      background-color:white;&lt;br /&gt;      left:0px;&lt;br /&gt;      top:0px;&lt;br /&gt;      width:500px;&lt;br /&gt;      height:500px;&lt;br /&gt;      border: 1px solid #999;&lt;br /&gt;      padding-top: 5px;&lt;br /&gt;      padding-left: 5px;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    .proxy {&lt;br /&gt;     border: 1px dashed #000;&lt;br /&gt;     z-index:9999;&lt;br /&gt;    }&lt;br /&gt;  &amp;lt;/style&amp;gt;&lt;br /&gt;  &lt;br /&gt;  &lt;br /&gt;  &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;    function expandDiv(containerName, newWidth, newHeight) {&lt;br /&gt;      containerName = '#' + containerName;&lt;br /&gt;      var shadowContainer = $(containerName);&lt;br /&gt;      var oldWidth = $(shadowContainer).width();&lt;br /&gt;      var oldHeight = $(shadowContainer).height();&lt;br /&gt;      &lt;br /&gt;      var changeWidth = newWidth - oldWidth;&lt;br /&gt;      var changeHeight = newHeight - oldHeight;&lt;br /&gt;      &lt;br /&gt;      // Make bottom 1px shadow width change&lt;br /&gt;      var bShadow = $(containerName + &amp;quot; div.bShadow&amp;quot;)[0];&lt;br /&gt;      var bShadowWidth = $(bShadow).width();&lt;br /&gt;      var newBShadowWidth = bShadowWidth + changeWidth;&lt;br /&gt;      $(bShadow).css('width', newBShadowWidth + 'px');&lt;br /&gt;      &lt;br /&gt;      // Make right 1px shadow height change&lt;br /&gt;      var rShadow = $(containerName + &amp;quot; div.rShadow&amp;quot;)[0];&lt;br /&gt;      var rShadowHeight = $(rShadow).height();&lt;br /&gt;      var newRShadowHeight = rShadowHeight + changeHeight;&lt;br /&gt;      $(rShadow).css('height', newRShadowHeight + 'px');&lt;br /&gt;      &lt;br /&gt;      var bShadows = $(containerName + &amp;quot; .bottomShadows&amp;quot;);&lt;br /&gt;      var bShadowsCurTop = $(bShadows[0]).position().top;&lt;br /&gt;      // alert(bShadowsCurTop);&lt;br /&gt;      var newBShadowsTop = bShadowsCurTop + changeHeight;&lt;br /&gt;      $(bShadows).css('top', newBShadowsTop + 'px');&lt;br /&gt;      &lt;br /&gt;      $(shadowContainer).css('width', newWidth + 'px').css('height', newHeight + 'px');&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;  &amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;  &amp;lt;div id=&amp;quot;shadowContainer&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;div class=&amp;quot;blShadow bottomShadows&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;div class=&amp;quot;bShadow bottomShadows&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;div class=&amp;quot;brShadow bottomShadows rightShadows&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;div class=&amp;quot;rShadow rightShadows&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;div class=&amp;quot;trShadow rightShadows&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;  &amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;div id=&amp;quot;topDiv&amp;quot;&amp;gt;This is my awesome DIV&amp;lt;/div&amp;gt;&lt;br /&gt;  &lt;br /&gt;  &lt;br /&gt;  &lt;br /&gt;  &amp;lt;input type=&amp;quot;button&amp;quot; style=&amp;quot;position:absolute; top:1000px;&amp;quot; value=&amp;quot;bigger&amp;quot; onclick=&amp;quot;expandDiv('shadowContainer', 600, 700);&amp;quot;/&amp;gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;br /&gt;  &amp;lt;script type=&amp;quot;text/javascript&amp;quot; charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;    $(&amp;quot;#topDiv&amp;quot;).resizable({&lt;br /&gt;      handles: &amp;quot;s,se,e&amp;quot;,&lt;br /&gt;      helper: &amp;quot;proxy&amp;quot;,&lt;br /&gt;      stop: function(e, ui) {expandDiv('shadowContainer', ui.size.width, ui.size.height);}&lt;br /&gt;    });&lt;br /&gt;  &amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;5) Please, shadow responsibly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3698186131165328823-8747553592408305492?l=buildingonmud.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://buildingonmud.blogspot.com/feeds/8747553592408305492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3698186131165328823&amp;postID=8747553592408305492' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/8747553592408305492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3698186131165328823/posts/default/8747553592408305492'/><link rel='alternate' type='text/html' href='http://buildingonmud.blogspot.com/2008/10/drop-shadow-on-any-div-scalable.html' title='Drop shadow on any div, scalable'/><author><name>Ben Lisbakken</name><uri>http://www.blogger.com/profile/07310171879372717926</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>
