Posted By

Teff on 02/08/12


Tagged


Versions (?)

A link should behave like a link!


 / Published in: JavaScript
 

URL: http://warpspire.com/posts/url-design/

  1. $('a.ajaxylink').click(function(e){
  2. // Fallback for browser that don't support the history API
  3. if (!('replaceState' in window.history)) return true
  4.  
  5. // Ensure middle, control and command clicks act normally
  6. if (e.which == 2 || e.metaKey || e.ctrlKey){
  7. return true
  8. }
  9.  
  10. // Do something awesome, then change the URL
  11. window.history.replaceState(null, "New Title", '/some/cool/url')
  12. return false
  13. })

Report this snippet  

You need to login to post a comment.