Revision: 55486
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 8, 2012 23:40 by Teff
Initial Code
$('a.ajaxylink').click(function(e){ // Fallback for browser that don't support the history API if (!('replaceState' in window.history)) return true // Ensure middle, control and command clicks act normally if (e.which == 2 || e.metaKey || e.ctrlKey){ return true } // Do something awesome, then change the URL window.history.replaceState(null, "New Title", '/some/cool/url') return false })
Initial URL
http://warpspire.com/posts/url-design/
Initial Description
/* * There’s a lot of awesome functionality built into linking elements like <a> and <button>. * If you middle click or command-click on them they’ll open in new windows. * When you hover over an <a> your browser tells you the URL in the status bar. * Don’t break this behavior when playing with onReplaceState and onPushState. * Embed the location of AJAX requests in the href attributes of anchor elements. * Return true from Javascript click handlers when people middle or command click. * * http://warpspire.com/posts/url-design/ */
Initial Title
A link should behave like a link!
Initial Tags
Initial Language
JavaScript