[英]Programatically open the URL in new tab in chromium browser using javascript
I have a web application where I have four/five icons in the default page. 我有一个Web应用程序,在默认页面中有四个/五个图标。 On click of these icons i am redirecting to some URL in new tab of already opened chromium browser instance using javascript.
单击这些图标后,我将使用javascript重定向到已经打开的Chrome浏览器实例的新标签中的某个URL。 Below is the javascript code snippet that I am using to launch the URL in new tab of already opened chromium browser instance.
以下是我用来在已打开的Chrome浏览器实例的新标签页中启动URL的javascript代码段。 Here I am manually clicking the icon
在这里,我手动单击图标
window.open(myURL, '_blank');
But the issue is when I am trying to open the same URL using the same code and programatically triggering the same code to open the URL in new tab, it opes up as a Pop Up but not in a tab. 但是问题是,当我尝试使用相同的代码打开相同的URL并以编程方式触发相同的代码以在新选项卡中打开URL时,它会弹出菜单而不是在选项卡中。 Below is how I am trying to pragmatically open the URL.
以下是我尝试以实用的方式打开URL的方法。 I am calling the click event of the Icon in the default page using some script rather than manually clicking the icon.
我使用一些脚本而不是手动单击图标在默认页面中调用图标的click事件。
$('#myIconId').click();
If somebody could please help me out. 如果有人可以帮助我。 TIA
TIA
give a try to use 尝试使用
<a href="some url" target="_newtab">content of the anchor</a>
Although You shouldn't force user to open new pages or new tab without showing them a hint on what is going to happen before they click on the link. 尽管您不应该在用户单击链接之前不强迫用户打开新页面或新选项卡而不向他们显示即将发生的情况的提示。
Above code may or may not work on all browser, please test before making live. 上面的代码可能无法或不能在所有浏览器上运行,请在启用前进行测试。
UPDATE 更新
Ref : Programmatically open new pages on Tabs 参考:以编程方式在选项卡上打开新页面
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.