简体   繁体   English

目标的jQuery属性用法

[英]jQuery Attribute Usage for Target

Can anyone see why the following code is not causing my url top open up in a new window, ie: 谁能看到以下代码为什么没有在新窗口中打开我的网址顶部,即:

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

where toLoad is my url. toLoad是我的网址。

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. jQuery包装器用于DOM元素,而不是任意对象,并且locationwindow.location )甚至没有target属性。 Simply do a window.open(...) . 只需做一个window.open(...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM