简体   繁体   English

使用javascript在Chrome浏览器的新标签页中以编程方式打开URL

[英]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.

相关问题 在磁盘上的新浏览器选项卡中使用 javascript 以编程方式打开 html 文件 - Open an html file programatically using javascript in a new browser tab from disk 使用Javascript在新标签页中打开URL - Open URL's in new tab using Javascript 使用javascript在IE浏览器的新标签页中打开URL的最佳方法是什么? - What is best way to open URL in new tab in IE browser using javascript? 使用JavaScript在Google Chrome浏览器的打开新标签页窗口中出现的问题 - Issue in open new tab window for Google Chrome Browser using javascript 如何打开新的浏览器窗口(不是选项卡),然后使用jQuery / Javascript调整其大小 - How to open new browser window (not tab) and then resize it using jQuery / Javascript 浏览器打开一个新选项卡并禁用 url 编辑 - Browser open a new tab and disable url edit Mac safari使用javascript在新标签页/窗口中打开一个URL - Mac safari open a URL in new tab/window using javascript 使用javascript在新标签中打开网址,而无需单击锚点 - Open url in new tab using javascript without click an anchor JavaScript在新标签页中打开,而不是Chrome浏览器中的窗口 - JavaScript open in a new tab, not window in Chrome browser javascript在新选项卡中打开间接URL链接 - javascript open indirect URL link in new tab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM