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(...)
.
精彩评论