使用javascript在Chrome浏览器的新标签页中以编程方式打开URL [英] Programatically open the URL in new tab in chromium browser using javascript

查看:425
本文介绍了使用javascript在Chrome浏览器的新标签页中以编程方式打开URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,在默认页面中有四个/五个图标.单击这些图标后,我将使用javascript重定向到已经打开的Chrome浏览器实例的新标签中的某个URL.以下是我用来在已打开的Chrome浏览器实例的新标签页中启动URL的javascript代码段.在这里,我手动单击图标

I have a web application where I have four/five icons in the default page. On click of these icons i am redirecting to some URL in new tab of already opened chromium browser instance using javascript. Below is the javascript code snippet that I am using to launch the URL in new tab of already opened chromium browser instance. Here I am manually clicking the icon

window.open(myURL, '_blank');

但是问题是,当我尝试使用相同的代码打开相同的URL并以编程方式触发相同的代码以在新选项卡中打开URL时,它会弹出菜单,而不是在选项卡中.以下是我尝试以实用的方式打开URL的方法.我正在使用某些脚本而不是手动单击图标在默认页面中调用图标的click事件.

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. Below is how I am trying to pragmatically open the URL. I am calling the click event of the Icon in the default page using some script rather than manually clicking the icon.

$('#myIconId').click();

如果有人可以帮助我. TIA

If somebody could please help me out. TIA

推荐答案

尝试使用

<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.

更新

Ref:以编程方式在标签上打开新页面

这篇关于使用javascript在Chrome浏览器的新标签页中以编程方式打开URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆