tags:

views:

20

answers:

1

Hi,

Can anyone see why the following code is not causing my url top open up in a new window, i.e:

        $(location).attr({
            href: toLoad,
            target: "_blank"
        });

where toLoad is my url.

Looking at the view source, all seems fine and basically looks like:

<a target="_blank" title="" href="http://......etc"&gt;ccc&lt;/a&gt;

Any ideas what I could be doing wrong?

Thanks.

+1  A: 

The jQuery wrapper is used for DOM elements, not arbitrary objects, and location (window.location) doesn't even have a target attribute. Simply do a window.open(...).

Max Shawabkeh
Thanks for the info Max.
tonsils