Re: opening link in new window

From: Date: Sat, 24 Jul 2010 14:20:03 +0000
Subject: Re: opening link in new window
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-307131@lists.php.net to get a copy of this message
On 10-07-24 04:19 AM, Adam Richardson wrote:
Code that resembled the below is how I used to open new windows before I started using jQuery Note, this completely avoids use of the target attribute. function wireNewWindows(){
    if(document.getElementsByTagName){
       var anchors = document.getElementsByTagName("a");
       for(var i = 0; i<  anchors.length; i++){
          var node = anchors[i];
          if(node.getAttribute('rel') == 'external' ||
node.getAttribute('rel') == 'nofollow'){
             node.onclick = function(){
                var url = this.href;
                window.open(
                   url,
'newWin','width=700,height=500,Menubar=yes,Toolbar=no,Location=no'
                );
                return false;
             }
          }
       }
    }
}
I try to avoid window.open() due to the proliferation of popup blocking. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized.

« previous php.general (#307131) next »