Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have a php site.users opens the site in multiple tabs in same browser.now when user in any tab and browsing my site i want to find current tabid of tabinfo by which i can identify current tab.how do i do if needed by javascript too? for mozilla,ie,chrome browsers.Any expert asap?

regards,
mridul
Posted
Comments
Niral Soni 2-Jan-13 5:13am    
I will be glad if you tell me the reason for such a unique requirement.
mridul samadder 2-Jan-13 16:15pm    
in brief.i need so that i can login and work in each tab as a seperate user.
Karthik. A 2-Jan-13 16:17pm    
Why not simply use different browsers for different users, if this is only for testing purposes?
mridul samadder 3-Jan-13 6:07am    
no there are other requirements

1 solution

This seems that you want to test your application with different user(roles) and don't want to get into the repetitive activities like login. It is a good idea to speed up and save time.

But as far as I am aware, this is not possible. Reason is -

1) There is no way of identifying whether the browser supports tabs or not.

2) Even if you found a way to get this, browser window can be opened either as a new tab or as new window. So, your code will not work.

3) Browsers like Google Chrome allows user to drag the tabs to make it as another window, or merge multiple windows into single window with multiple tabs. In such cases, your code will not work.

4) Browsers preserves the session values (eg. login user session ids for same domain) and they are shared across the tabs. So, for the same domain, even if you login as different users in different tabs, the most recent session values (means the login id) will be active. To check this, try to open multiple gmail accounts in multiple tabs. It will always open the account of the most recent logged-in user.

Hence I would prefer to use different browsers for login as different user(roles) and use ALT+TAB key to switch between the open windows.

Hope it helps you out...

If you find a solution for this, please do share with us.

Regards,
Niral Soni
 
Share this answer
 
Comments
mridul samadder 3-Jan-13 14:11pm    
dear niral
thank you!.As client wants it so what can i do.i found a way 'window.name' property is unique per tab in a browser.so i am trying to use it..will there be any problem when i assign unique value to window.name when any tab loaded with site to achieve my goal?
Niral Soni 4-Jan-13 10:32am    
You can give it a try. As window.name is mere a JavaScript that runs on client side, the actual problem will arise for maintaining the session values for different users in same browser window with different tabs.

All the best !!!
mridul samadder 6-Jan-13 14:17pm    
no problem.when user comes in a tab i make him relogin if needed for that tab

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900