任何方法来识别使用JavaScript的浏览器标签? [英] Any way to identify browser tab in JavaScript?

查看:108
本文介绍了任何方法来识别使用JavaScript的浏览器标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够识别我是什么标签在浏览器中。是不是有一些信息,我可以从浏览器中得到识别标签?我并不需要知道任何其他选项卡中任何东西,我只需要我在标签的ID。这可能是一个随机或连续数字或日期时间戳,只要它仍然是相同的标签的使用寿命。

I need to be able to identify what tab I am in within the browser. Isn't there some bit of information I can get from the browser to identify the tab? I don't need to know anything about any other tabs, I just need an id for the tab I am in. It could be a random or sequenced number, or a date-time stamp, as long as it remains the same for the life of the tab.

我有一个客户端应用程序,使一个BOSH over HTTP连接到远程服务器,如果我在多个标签页中打开它,每个实例都需要自己独特的ID或应用程序出现故障,所以我只是需要一些独特的数字与选项卡关联,只要该选项卡存在(即东西生存页面刷新为我导航,提供这个应用程序的站点)。似乎是一个没有脑子应该只是在浏览器中可用,像window.tabId - 这就是我所需要的。我有一个严重的开发区块,因为我不能让过去这个简单的,简单的,简单的解决方案似乎并不存在。必须有一种方法(在该跨浏览器溶液)。

I have a client side app that makes a BOSH over HTTP connection to a remote server, and if I open it in multiple tabs, each instance needs its own unique id or the app fails, so I just need some unique number that is associated with the tab for as long as that tab exists (i.e. something that survives page refresh as I navigate the site that provides this app). Seems like a no-brainer that should just be available in the browser, like window.tabId - that's all I need. I've got a serious development block because I cannot get past this simple, simple, simple solution that doesn't seem to exist. There must be a way (a cross-browser solution at that).

任何想法?

推荐答案

您必须使用HTML5是,但的的sessionStorage ,提供一个随机的GUID相结合,似乎是你想要的。

You have to be using html5, but sessionStorage combined with a random guid would seem to be what you want.

这篇关于任何方法来识别使用JavaScript的浏览器标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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