开发者

jQuery Attribute Usage for Target

Can anyone see why the following c开发者_开发技巧ode 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">ccc</a>

Any ideas what I could be doing wrong?

Thanks.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜