Jesse TraynhamA mixed bag of FileMaker, Lasso, AppleScript, Photography, web designing, and more... |
||||||||||||||||||||||||||||||||||||||||||||||||||
Bookmarklets: CD (Change Directory)For quite a long time now, I've had a bookmarklet in the first position of my bookmarks bar in Safari which will load the web page above whatever page I am currently viewing. This can come in very handy when you land on a page from a search engine and you'd like to see what else might be on the site. For example, say I am on FileMaker's website looking at documentation at http://www.filemaker.com/developers/resources/documentation.htmlWhen I click my bookmarklet, I end up at this url: http://www.filemaker.com/developers/resources/Click again, and end up at this url: http://www.filemaker.com/developers/And so on until I am at the root of the site: http://www.filemaker.com/ There are times though, when walking through the path is needless because there are no viewable pages available. It just depends on the website. Because of this, I've wanted to find a new bookmarklet that simply goes to the root of the site. After googling for a while, I came up dry, so it was time to write my own. I did find some example bookmarklets that made it easy to figure out at http://jan.moesen.nu/code/browser/bookmarks, specifically the "CD .." bookmarklet. Turns out it's so simple I don't know why I didn't try to do this earlier: javascript:location='/'; The code to move up a directory is a little more complex, but not to difficult to follow: javascript: if (location.pathname == '/'); else if (location.pathname.charAt(location.pathname.length - 1) == '/') location = '..'; else location = '.'; I have only tested these in Safari, so your mileage may vary. One cool thing is you can use command-# for bookmarks on your toolbar, where # is the number of the bookmark from the left. I've named these " • " and " •• ", and they are the first and second bookmarks on my bookmark bar. So to get to the root of a site, I just hit command-1, and to walk up the directories I hit command-2. To add these bookmarklets to your browser, simply drag the links below to your bookmarks bar: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||