HTML / Javascript - 导航到已经打开的浏览器选项卡/窗口 [英] HTML/Javascript - Navigate to an already opened browser tab/window

查看:133
本文介绍了HTML / Javascript - 导航到已经打开的浏览器选项卡/窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个拥有信息中心页面的应用程序。仪表板页面上的不同链接会根据用户的浏览器设置作为不同的浏览器选项卡或窗口打开。每个打开的新页面/标签在标题中都有一个返回按钮。该应用程序使用引导框架进行布局。

I have an application that has a dashboard page. Different links on the dashboard page open as different browser tabs or windows based on the user's browser setting. Each new page/tab opened has a "Go back" button in the header. The application uses bootstrap framework for layout.

我在之后的新页面中,当用户点击 strong>回到按钮,我希望用户被带回仪表板页面/标签页。(请注意,我没有在当前页面上加载仪表板页面。

What I'm after is, on the new page, when a user clicks on the "Go back" button", I'd like the user to be taken back to the dashboard page/tab. (Please note, I'm not after loading the dashboard page on the current page.

这是可以实现的吗?如果是的话,我可以请求一个例子吗?

Is this achievable? If yes, can I please request an example?

推荐答案

正如你可能从评论中猜到的那样,你不能这样做(当然不是以任何标准化的,被接受的和未来的证明方式),而且这也是一件好事,因为过去广告客户可能(并已被)滥用并且通常是不好的做法。

As you may have guessed from the comments, you can't do this (certainly not in any standardised, accepted and future proof way), and it's a good thing too as this could (and has been) abused in the past by advertisers and is generally bad practice.

作为一般规则,您不应该通过打开一个新的窗口/标签来劫持用户预期的点击链接的行为。如果用户希望在新标签中显示,他们可以右键单击该链接并点击在新标签中打开。只有在极少数情况下,您应该强制在新窗口中打开。

As a general rule you shouldn't be hijacking the users expected behaviour of clicking on a link by opening it a new window/tab anyway. If the user wants it in a new tab, they can just right click the link and 'Open in New Tab'. It's only in rare cases that you should be forcing things to open in a new window.

请记住,当您强制在新窗口中打开某些内容时,您也打破了后退按钮的预期行为。当有人点击你的链接之一,但突然意识到他们不想在那里,他们会做的第一件事是什么,点击后退按钮。但现在它不会回头,他们必须点击某个地方的链接,或者关闭新窗口,但他们可能没有注意到开始的时间。不要低估后退按钮的用处,这是用户弹出式座椅。 将其分解为危险

Remember that when you force something to open in new window you are also breaking the expected behaviour of the back button. When someone clicks one of your links but suddenly realises they didn't want to be there, what's the first thing they'll do, hit the back button. But now it doesn't go back, they have to either click a link you've put in somewhere or close the new window, which they may not have noticed opening to begin with. Don't underestimate the usefulness of the back button, it's the users ejector seat. Break it at your peril.

在这里您给我们的例子

In the example you gave us here


仪表板页面上的不同链接作为不同的浏览器标签打开
或windows

Different links on the dashboard page open as different browser tabs or windows

我只有一个问题。为什么?您是否有一个非常有道理的信息显示板页面无法导航?你已经说过你正在放置一个'返回'按钮,用户后退按钮也会这样做,所以它不会像他们永远不会回到页面。也许用户以某种方式定制了他们的仪表板?在这种情况下,可能考虑使用本地存储或cookie的方式保存其状态。

I have just one question. Why? Do you have a very valid reason that the dashboard page can't be navigated away from? You've said you're putting in a 'go back' button, and the users back button will do that as well, so it's not like they're never going to get back to the page. Maybe the user has customised their dashboard in some way? In which case maybe considering saving their state using something along the lines of localstorage or cookies.

可能有许多原因希望实现此目的,他们可以是有效的,但是因为你真的不可能现在是重新考虑一些关于UI如何工作的假设的好时机。您可以通过 http://ux.stackexchange.com 获取有关UI问题的帮助。

There could be any number of reasons you are wanting to achieve this, and they could be valid, but since you really can't maybe it's a good time to rethink some of your assumptions about how the UI should work. You could get help with UI questions over at http://ux.stackexchange.com

这篇关于HTML / Javascript - 导航到已经打开的浏览器选项卡/窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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