JavaScript open links in new window Oct22 '06 I've recently adopted this Sitepoint approach to opening links in new browser windows. Using this method, all I have to do is apply an attribute of rel="external" to any link that I wish to open in a new browser window. To me, this is much more preferable (and standards-compliant) than using target="_blank". The JavaScript function (obtained from Sitepoint) that controls this is relatively straight-forward. I also made an addition to the function that controls links that you want to open in the same external browser window. In other words, you open the external window once, and then every additional link opens in that same external window (as opposed to a new window each time). function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for ( var i=0; i < anchors.length; i++ ) { var anchor = anchors[i]; if ( anchor.getAttribute("href") && anchor.getAttribute("rel") == "external" ) { if ( anchor.getAttribute("className") ) { anchor.target = anchor.getAttribute("className"); } else { anchor.target = "_blank"; } } } } For explanation on how the function works, please see the original Sitepoint article. My addition, which is not part of the original script from Sitepoint, is in bold. It checks to see if the class attribute is set for the <a> element. If so, it uses that class attribute value as the name of the external window. So, as long as every link (that you wish to have open in the same external window) has the same class attribute - all of those links will open in the same parent window. For example, here are three links that I want to open in the same external window: <a href="link1.php" mce_href="link1.php" class="newWindow" rel="external"> Link 1 </a> <a href="link2.php" mce_href="link2.php" class="newWindow" rel="external"> Link 2 </a> <a href="link3.php" mce_href="link3.php" class="newWindow" rel="external"> Link 3 </a> Here are two more links that will open in an external window, but not the same one as the above three links: <a href="link4.php" mce_href="link4.php" class="differentWindow" rel="external"> Link 4 </a> <a href="link5.php" mce_href="link5.php" rel="external"> Link 5 </a> Notice the class attribute value has changed in Link 4, and the class attribute doesn't even exist in Link 5. Cautions This entire script has only been tested in Firefox 1.5.x for Windows, and Internet Explorer 6. There is also the slight problem of window focus. For example, if I click on a link that uses an existing window as it's destination, the focus should be placed on that window. It is currently not happening that way. Additions to this script may be made over time.