如果它已经在浏览器中打开,如何打开同一个选项卡的 url [英] How to open url to the same tab if its already open in browser

查看:17
本文介绍了如果它已经在浏览器中打开,如何打开同一个选项卡的 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临一些挑战-让我们考虑一下我有一个菜单,下面有 3 个链接-

I am facing some challenge- Lets consider I have a menu and under that I have 3 links-

About
Contact Us
FAQs

默认主页是关于菜单项.现在,当我点击联系我们"时,我想在同一个浏览器窗口中打开一个新标签.如果我再次点击第一个选项卡中的联系我们"而不关闭它,这次我不想打开新选项卡,因为我已经打开了联系我们的选项卡,我只是想导航到之前打开的同一个.在jsp中如何处理这种情况.

By default home page is About menu item. Now when I am clicking on "Contact Us" , I want to open a new tab on same browser window. And without closing this if again I am clinking on "Contact Us" from the first tab, this time I do not want to open new tab because I have already an open tab for Contact us, I just wanted to navigate to the same one which is earlier opened. How to handle this scenario in jsp.

有没有办法做到这一点.请帮帮我.

Is there any way to do this. please help me.

推荐答案

你总是可以在目标中放一个名字,所以它总是会转到同一个窗口/标签

you can always put a name in the target so it will always go to the same window/tab

<a href="somerandomurl.com" target="mywindow">Contact Us<a>

在 Internet Explorer 上无法控制.但是,您可以更改 IE 的行为方式:-互联网选项-标签- 始终在新标签页中打开弹出窗口- 从其他程序中打开链接:当前窗口中的新选项卡

Its not possible to control this on Internet explorer. You can however change how IE behaves: -Internet Options -Tabs -Always open pop-ups in a new tab -Open links from other programs in: A new tab in the current window

target="_blank" 将始终确保它在新窗口中打开http://www.w3schools.com/tags/att_a_target.asp

target="_blank" will always make sure it opens in a new window http://www.w3schools.com/tags/att_a_target.asp

但它会使用相同的 url 刷新页面

It will however refresh the page with the same url

您可以让链接返回一个 javascript 窗口对象,并且可以随时返回窗口而无需刷新页面

You can have the link return a javascript window object and be able to return to the window anytime you want without refreshing the page

var newtab = null;

function openwindow(){
  if (newtab==null) {
    newtab = window.open("www.example.com");
  } else {
    newtab.focus();
  }

}

<a onclick="openwindow()">click me</a>

这篇关于如果它已经在浏览器中打开,如何打开同一个选项卡的 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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