On Sat, Jul 24, 2010 at 10:20 AM, Robert Cummings <rob...@interjinn.com>wrote:

> 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.

Hi Rob,

I agree, popup blockers are certainly a concern.  However, most browsers
appear to have a very focused definition of what constitutes a popup window.
 To my, albeit limited, knowledge, programmatically opening a new window in
response to a user click is not blocked by the popup blockers provided by
Mozilla, Safari, and IE 8 (although the default setting can be changed to
block popups initiated by a user click, and this includes changing the
behavior of the target attribute, too):

(key phrase on this page is "Google Chrome blocks popups from *automatically
* appearing", emphasis added.)

that are sneaky (delayed response to click, mouse gesture, open immediately
when you view the page, etc.) are much more likely to be blocked by various
browsers, and the popup blocker tests I'm familiar with focus on these
specific types of nefarious activity:


So, most of the time you can use window.open() to create a new window,  stay
true to the DTD you're using DOM scripting to manipulate, and avoid issues
due to popup blockers.  However, as is always the case, testing your
particular implementation across the range of browsers representative of
your intended audience is of paramount importance (i.e., don't blame me if
you have issues because you didn't test your particular use cases ;)


Nephtali:  PHP web framework that functions beautifully

Reply via email to