offsite-newwin explanation

Short Explanation

Note: If you use a browser such as Mozilla that has support for CSS3, you will see the word "off-site" display when you hover over an external link.

Here is an example link to Google.

Background Info

for a long time, i couldn't decide how to link offsite pages. the way i browse -- and the most efficient way to browse, in my opinion -- is to open new windows for links that take you off a site. so this preference was reflected in the way i linked offsite pages from underscorebleach.net. i'd link everything offsite with a "target=_blank" attribute.

problem is, a lot of people don't like that, and they have a legitimate point. even though i like to browse offsite pages with new windows, lots of people like to stay in the same window, and target=_blank doesn't allow you to do that. besides, target=_blank is deprecated in the new HTML 4.01 DTD. so the smart guy at my former workplace, Adam, had a good suggestion for me: give people a choice.

so here's the deal. if you want offsite windows to open in a new window, check the box at the top of the window. offsite links will be opened in a new window, and that window will then be pushed to the background (similar to Opera's "Open in background" right-click function, which i use constantly). if you prefer not to have offsite links launch in a new window, leave the box unchecked. whatever your choice, it will be saved in a cookie for your browseriffic convenience.

Technical Crap

curious as to how this works? probably not. but for the dorks out there, here goes...

offsite links are linked in the following way:

<A HREF="http://www.foo.com" ONCLICK="v('http://www.foo.com'); return false">link<A>

the "onclick" event handler passes the URL to a javascript function called "v". this function takes a look at whether you've decided to use offsite new windows or not, and depending on your choice, loads the URL in the base window or in a new window. if it loads the URL in a new window, it then pushes the new window to the background.

if you are in a browser without javascript, or if you've got javascript turned off, this functions as a normal link. this is a very good thing, because otherwise, people without javascript would be S.O.L.

and that's it! i wrote the code myself. yay. go me. i've never seen anyone else implement something exactly like this, but i can't take credit for the idea; Adam came up with it. you may have seen something similar on other sites that have a checkbox for opening links in new windows, but this applies to all windows, and my suspicion is that they're using a simple document.write of the <BASE> tag.


the real deal here is the jotsheet.