The target attribute in HTML was declared to be obsolete with support for it to be dropped in a future version (in other words 'deprecated') because it was felt that the visitors to a page should be the ones to decide where it opens. Also with the introduction of tabs there are now three different places where a page can be opened and attempting to force it to open in a particular place simply restricts some visitors' options with still no guarantee that it will open where you want.
In implementing our solution this way we not only end up with something that can easily be added to web pages at any time without needing to make any changes to the HTML (except perhaps to add one extra script tag) but we also get to see how the modern unobtrusive way of attaching events into a web page works and acquire a few standard functions that can be reused for any other event processing that we want to unobtrusively add.
The final function is the one that attaches the newWin function to all of the external links in the web page. It finds all the <a> tags on the page and for all of those where the href starts with 'http://' it attaches the newWin function so that it will run if that link is clicked.
This article written by Stephen Chapman, Felgall Pty Ltd.