<link rel="up" href="..."> tag and uses it if there is one; if there isn't, it chops the last part off the URL.
And this is An "up" button in the browser, written , and concerning JavaScript and the DOM, Web
Comments
Instead of parsing the current location, would a simple location.href = '../' do the trick?
The Epiphany browser has a "go up" feature as long as I can remember...
http://addons.mozilla.org/en-US/firefox/addon/167 7 does the same thing.
Jonathan: cheezit, if I had half a brain I'd be dangerous. Never thought of that. :-)
@Sven - yes, that was a feature old Mozilla and Netscape had, not sure if it remains in SeaMonkey. I seem to recall it needed some meta tags on the page in order to work, but it might be possible for an extension to take a guess at where next/prev should go by looking in the DOM...
whatever
This bookmarklet is more fine-grained, though I don’t think it looks for any link tags.
The link toolbar has been in Mozilla/SeaMonkey forever, and Seamonkey 1.1 binds alt-up arrow to "go up a directory".
The default Gnome web browser got an up button, and you can even press +". Unfortunately most distros ships some other browser with Gnome :/
Seams like my post was hurt a bit by some prepocessing.
Anyway, you can just press "the Alt button" pluss "the Up button" in Epiphany to achieve what you want.
Konqueror also includes an Up button.
If you use Firefox as your Browser you should check out the Locationbar² extension which "linkifies" all parts of a URL:
It looks like this:
http://www.example.org/parts/of/the/URL/file.html and every of the underlined parts is clickable (plus the optional marking of the main server name is kind neat)
The Google Toolbar for firefox also has an "up" button. That and search word highlighting are the main reasons I keep that extension around.
@Jonathan: No it wouldn't. is about the structure of a (set of) document(s), not about the file system structure. Let's say you have chapter 1, (http://example.com/1.html) which has a section 1.1 (http://example.com/1.1.html), and http://example.com/1.1.html has an "up" link to http://example.com/1.html . Both files are in the same directory, yet you're still navigating "up".
the other thing I was going to suggest was to skip assigning to a var and just change location in the loop and exit the function. Then it'd only do the '../' if it didn't exit within the loop. You might be able to shave a few bytes (not that it really matters).
Code: twenty different ways to do the same thing and cocky bastards have no hesitation in pointing out what they are. ;)
Blimey, this code has been more reviewed than anything else I've ever written. ;)
I think I first remember seeing this in Konquoror. I used to use that as my primary browser in the pre-firefox days because it was faster than netscape/mozilla on my desktop at the time. I've missed it ever since, only recently discovering that epiphany has it too (just not on the toolbar by default)
I have no idea why that was submitted full of non-breaking spaces. I apologise!
I very much like the "Link Widgets" Firefox extension which does not only add an Up button, but also Previous and Next.