获取浏览器选项卡索引/ ID [英] Get Browser Tab Index/Id

查看:643
本文介绍了获取浏览器选项卡索引/ ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,在最新的浏览器有标签的功能,有没有办法让标签指数?

So in most current browsers there is the feature of Tabs, is there a way to get the Tab index?

所以选项卡1已经在www.google.com开业和Tab 2已经在www.google.com它打开了,有没有办法来识别标签指数是什么?

so Tab 1 has www.google.com opened in it and Tab 2 has www.google.com opened in it, is there a way to identify what the Tab index is?

伪code:

if($tab == 2) {
  alert "Tab 2 is active\n";
}

if($tab == 1) {
  alert "Please use Tab 2 as this is Tab 1\n";
}

有趣,因为一切我搜索有关的标签是关系到网页本身的选项卡索引,叹了口气......

Funny as everything I search for about tabs is related to the tab index of the webpage itself, sigh...

推荐答案

严格地说。 TABS是最终用户的计算机上。 PHP可以在服务器上。 PHP无法看到最终用户的机器是干什么的,它只能服务终端用户PHP'ed页。

Strictly speaking. TABS are on the end user's machine. PHP works on the server. PHP can't see what the end user's machine is doing, it can only serve the end user PHP'ed pages.

谷歌做到这一点的JavaScript和Cookies。对于打开页面的每个实例,增加一个cookie计数器。如果计数器> 1,使用AJAX来显示错误消息。此外,从正常,如果cookie或禁用JavaScript禁止的网页。

Google does this with JavaScript and Cookies. For every instance of the page opened, increment a cookie counter. If the counter > 1, use AJAX to display an error message. Also, prohibit the page from functioning if cookies or JavaScript is disabled.

。看看jQuery的。

Look into jQuery.

这篇关于获取浏览器选项卡索引/ ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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