[UPHPU] xhtml strict and open in new window

Mac Newbold mac at macnewbold.com
Wed May 10 21:21:28 MDT 2006


Today at 4:58pm, Tyler Gee said:

>> This part would normally redirect the current window to test.com:
>>
>>   <a href="http://test.com/">Link Text</a>
>> 
>> Does this:
>>
>>   <a href="http://test.com/" onclick="window.open(this.href); return
>> false;">Link Text</a>
>> 
>> keep the current window where it is (in my case, mscis.org), but open a
>> new window that goes to test.com?

Yes, it should keep the current window where it is.

> I'm not sure...that was the method I recommended NOT doing.
>
> If you specify the ref="extrernal" attribute and then rewrite the
> target attribute in the DOM (as the articles did), there is no
> confusion as which which links will open in a new window and which
> ones will not.

Typo? I think it might be ref="external", but everyone probably knew what 
you meant.

> However, if you go with the approach above, you will need to have some
> additional javascript which stops the processing of the href attribute
> in the parent window, otherwise it would seem that it would open a new
> child window that points to test.com and redirect the parent window to
> test.com as well.  That might be what the 'return false;' is
> attempting, but I am pretty sure that doesn't stop processing in a
> cross-browser kind of way.

Actually, in my experience, that's exactly what it does. If you have a tag 
(<a>, <input>, etc.) with an onclick event, and that onclick event returns 
false, the other processing of it is stopped. So an <a> tag with an href 
and an onclick that ends in return false, the href won't be followed in 
the current window like normal. I've never had problems with it in MSIE, 
Firefox, or Safari.

It's funny that this came up on the list within 24 hours of us having a 
discussion about it at work... :)

Thanks,
Mac

--
Mac Newbold		MNE - Mac Newbold Enterprises, LLC
mac at macnewbold.com	http://www.macnewbold.com/


More information about the UPHPU mailing list