Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript PHP jQuery
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 1-Jan-13 23:45pm
Comments
Niral Soni at 2-Jan-13 5:13am
   
I will be glad if you tell me the reason for such a unique requirement.
mridul samadder at 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 at 2-Jan-13 16:17pm
   
Why not simply use different browsers for different users, if this is only for testing purposes?
mridul samadder at 3-Jan-13 6:07am
   
no there are other requirements

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
mridul samadder at 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 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 329
2 BillWoodruff 210
3 Afzaal Ahmad Zeeshan 204
4 CPallini 185
0 OriginalGriff 5,515
1 DamithSL 4,451
2 Maciej Los 3,902
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100