简体   繁体   English

带Window.Open的Chrome打开标签页

[英]Chrome Opening Tab With Window.Open

Have looked at the answers to previous questions and am not sure if it is the same issue as I am having. 看过先前问题的答案,不确定是否与我遇到的问题相同。 Some of the possible answers I have found on the net are aged so am not sure whether anything has changed regards this. 我在网上找到的一些可能答案已经过时,因此不确定是否对此有所更改。

I have this code to check for a cookie and then either open one or two tabs dependent on whether a cookie is found. 我有此代码来检查cookie,然后根据是否找到cookie打开一个或两个选项卡。

On the html side I have a link like this: 在html端,我有这样的链接:

<a target='_blank' onclick="newTab()" href="http://www.test.com">

In the head section the newTab() function does the cookie check then if needed opens a window like this: 在头部,newTab()函数进行cookie检查,然后根据需要打开一个如下窗口:

window.open('http://www.test.com/members/','_blank');

When the link is clicked the above works fine in Firefox and IE and both windows open when needed but in Chrome only the onclick tab opens and not the main url regardless of the cookie. 单击链接后,以上内容在Firefox和IE中均能正常运行,并且在需要时可以同时打开两个窗口,但是在Chrome中,仅打开onclick选项卡,而不打开主URL(无论cookie如何)。

I imagine this is an issue relating to opening tabs/windows in Chrome but I thought that the above would be dealt with by Chrome as the opening windows are the result of a user click. 我认为这是与在Chrome中打开标签页/窗口有关的问题,但是我认为上述问题将由Chrome处理,因为打开窗口是用户点击的结果。

Am I missing something simple or is it a restriction on Chrome? 我缺少简单的东西吗?还是Chrome的限制?

Thanks for any advice. 感谢您的任何建议。

Indeed as answered by CBroe the reason for the problems was because I had used _blank as the window name for both. 确实,正如CBroe回答的那样,出现问题的原因是因为我使用_blank作为两者的窗口名称。

I changed one over to _parent and it is at least working like this now so thanks for the assistance. 我将一个更改为_parent,并且至少现在这样工作,因此感谢您的帮助。

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

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