Posted By

f on 01/13/09


Tagged

siteIndependent


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

sulfurito


Go to the parent directory


 / Published in: JavaScript
 

URL: javascript: var url; if(location.hash) url = location.href.match(/.+#/); else if(location.search) url = location.href.match(/[^?]+/); else url = location.href.replace(/\/$/,

  1. http://www.imdb.com/help/show_leaf?datatopfaq#footer
  2. http://www.imdb.com/help/show_leaf?datatopfaq#
  3. http://www.imdb.com/help/show_leaf
  4. http://www.imdb.com/help/
  5. http://www.imdb.com/
  6. http://imdb.com/
  7. http://www.imdb.com/
  8. http://imdb.com/
  9. ......
  1. var url;
  2. if(location.hash)
  3. url = location.href.match(/.+#/);
  4. else if(location.search)
  5. url = location.href.match(/[^?]+/);
  6. else
  7. url = location.href.replace(/\/$/, "").match(/.*\//);
  8.  
  9. if(url != "http://")
  10. location.href = url;
  11. else if( location.hostname.match(/^www\./) )
  12. location.hostname = location.hostname.replace(/www\./, "");
  13. else
  14. location.hostname = "www." + location.hostname;
  15. undefined;

Report this snippet  

You need to login to post a comment.