Assume the Position

Thursday, December 12, 2002
How'd I get here? I like opening links in new windows (shift-click or right-click 'Open in New Window'). Then there are the sites that automatically do so or give the user a choice, like this one. So, when I'm surfing along, I sometimes have a dozen or two windows open. It's handy; I can quickly switch between the windows to compare what's being said by different writers and I don't have to wait for documents to reload.

But, there's one drawback when it comes to blogging: a new window has an empty history. I might open a bunch of links from Glenn Reynolds, several from Bill Quick, a few from other blogs on my blogroll, plus follow some secondary links. After closing some windows and opening still more, when I find something I feel like blogging about I may not remember how I got there. And an empty history means the 'Back' button has no URL to go back to. I wanted an answer to the question, "How'd I get here?"

That answer is the referrer information passed in the HTTP header and stored in the document.referrer object. I wanted a quick way to see it. Since I've already got a couple of quick scripts on my favorites list, that seemed the way to go. The result is a Favorite/Bookmark that pops up an alert box containing the referrer URL. (I first saw the script favorite/bookmark idea with the Free Me! Tool at SiteExperts. It's useful for breaking out of sites that spawn new windows whenever you try to close them.)

Just right-click on the "How'd I Get Here?" link and pick "Add to Favorites" or "Add Bookmark" on the pop-up menu. You can also drag the link to your links toolbar. IE might pop-up a warning that the favorite may not be safe, just press "Yes" to finish adding it. You can see the code itself in the status bar when the cursor is over the link, and I include the full code for the link right below it. If you left-click on the link itself it will work and show you how you got here (if the "Open off-site links in new windows" box at the top left of the page is checked, a blank window might open, also).

How'd I Get Here?

Link code:
<a href="javascript:alert(document.referrer)">How'd I Get Here?</a>
There are a few minor things to note. It won't always show a URL because some redirects strip referrer information, or you might have directly opened the page from your favorites list or typed the URL into the address bar, so there was no referrer, etc. Because I kept it to a simple alert box, you can't copy or open a window with displayed URL; but just seeing it should be enough of a reminder. (I fooled around with a few versions that print the URL in a new window, goto the URL, copy the URL to the clipboard, etc., but they were all rather clunky and I decided I like this simple one the best.)

Here's a bonus if you're interested in seeing what, if any, cookies a page is using. Install it to your Favorites/Bookmarks the same way. (I don't use any cookies here, but blogspot or the the ad banner might.)

Show Me The Cookies!

Link code:
<a href="javascript:alert(document.cookie)">Show Me The Cookies!</a>
Hope you find them useful.

Monday, December 09, 2002
The more things changeā€¦
Whatever his objective, any statement he makes - even mingled in with "ifs" - about extending the war in the Far East always sends huge shudders among the Canadian, French, British and other friendly governments. When the Europeans come in to the State Department wanting to know "what does MacArthur propose to do," Acheson and his aides get upset about the problems of holding together the political side of the coalition of which MacArthur is military commander.
-- Associated Press, March 26, 1951
(near the bottom of the linked page)

Original content copyright © 2002-2005 Lynxx Pherrett. All rights reserved.