Go to Home
The best ideas come from finding something you do all the time, realize you do it, and then automate it.
With me, I discovered that I frequently go to the base domain of a website by going to the URL, highlighting and deleting the junk on the end of the domain name and then pressing enter. I HATE doing it. I also have to do it when websites don’t link to their home page.
So here’s an easy solution. A bookmarklet!
Drag the link below to your bookmarks bar (or in IE, right-click and add to favorites):
Here is the code:
var url = new String(location.href);var re = new RegExp(’https?://([A-Za-z0-9.-]+)’);var res = url.match(re);location.href=res[0];
Enjoy :)

20 Comments, Comment or Ping
Goatrider
I didn’t realize I needed this until I saw it. Thank you, clever man.
Mar 23rd, 2008
Tolli
I do that a lot two, luckily I found a Firefox add-on that allows me to navigate up a level. It’s called uppity: https://addons.mozilla.org/en-US/firefox/addon/869
Aug 30th, 2008
John
Nice!
Aug 30th, 2008
Jeff
Thanks! This is one of those things you wonder how you did without.
Aug 30th, 2008
Teddy
Um… brilliant. Fucking brilliant.
Aug 30th, 2008
Xasey
Also, if one is using Safari they can right click on the page title at the top of the window to go to there as well.
Aug 30th, 2008
Lonestar
Here’s the ubiquity command for the same functionality:
CmdUtils.CreateCommand({
name: “root”,
_root: function() {
var doc = Application.activeWindow.activeTab.document;
var uri = doc.location.href;
var re = new RegExp(”^[A-Za-z0-9.-]+://([^/]+)”);
var res = uri.match(re);
return res && res[0];
},
preview: function(pblock) {
var msg = ‘Go to: “${rootUri}“‘;
pblock.innerHTML = CmdUtils.renderTemplate( msg, {rootUri: this._root()} );
},
execute: function() {
doc.location = this._root();
}
})
Aug 30th, 2008
nido
https://www.squarefree.com/bookmarklets/misc.html#top has been around forever, to save you some time in the future. There’s a ton more great ones on that site.
Aug 30th, 2008
nido
javascript:location.pathname = “”; void 0
is also much simpler :)
Aug 30th, 2008
Stu
Or.. just click on the logo of the website, will do it for 90% of websites
Aug 30th, 2008
Randall Merkin
Hi I tried dragging it to my address bar but I got this error:
[an error occurred while processing this directive]
Please check your code works in IE
Aug 30th, 2008
OJ
Or you could use the location bar plugin for Firefox. Does this and WAY more.
Aug 30th, 2008
Maray
Thank you !!!!
Aug 30th, 2008
SueDoc
Wonderful! Thank you!
Aug 30th, 2008
buccia
Also, the Vimperator plugin for Firefox does this (and also single-level-up) with the gu and gU keys.
Aug 30th, 2008
Bret Linford
Thanks, so much!
Aug 30th, 2008
Lisa
Pretty cool. Thanks!
Aug 30th, 2008
fearphage
This is very sad code. It is obvious you haven’t worked with javascript very much. For instance, location.href alread returns a string always. This code could be greatly simplified:
javascript:location.href = location.protocol + ‘//’ + location.host
Aug 31st, 2008
billy
Thanks everyone for the comments, suggestions and other product advice.
Fearphage — there’s always multiple ways to do something. That doesn’t make one worse than the other. location.host adds the port to the URL — I find that ugly.
Sep 1st, 2008
Reply to “Go to Home”