In my website, i want to check that whether the user has opened the homepage of my website in same tab again or in the new tab? Is there any solution to check that?
Asked
Active
Viewed 2,232 times
0
-
What do you mean "in the same tab again?" Are you trying to check whether he loaded the page fresh, or if he just reloaded the page? That is possible... – JasCav Oct 15 '13 at 13:57
-
@JasCav, How do we differentiate load fresh && reload in server side? Other than having a hidden field in the page value set to `loaded` and checking it in Request collection? :) – Murali Murugesan Oct 15 '13 at 14:03
-
Browsers don't maintain a constant connection to web servers, so it's not possible to *reliably* determine if a user has a web page open in more than one window. – Blazemonger Oct 15 '13 at 14:03
-
[This][1] post might help you! Please check. [1]: http://stackoverflow.com/questions/13455304/how-does-this-site-know-that-i-am-opening-another-tab – Sachin Gaur Oct 15 '13 at 14:05
1 Answers
1
The closest you can get is by checking to see if your current tab or window has any history...
if (history.length > 1) {
// you're in an old tab
} else {
// you're in a new tab
}
This is in Javascript, not server-side, but I don't see how you'd be able to detect anything like this in server-side code.

Reinstate Monica Cellio
- 25,975
- 6
- 51
- 67
-
I haven't used Firefox in a while, but it failed to preserve the history when opening a link on a new tab (Ctrl / Scroll-click). – CodeCaster Oct 15 '13 at 14:40
-
@CodeCaster That's the whole point. A new tab would only have 1 entry in the history. Or am I misunderstanding your comment? – Reinstate Monica Cellio Oct 15 '13 at 14:41
-
Well Chrome for example _does_ copy the history of the tab you're coming from, but also not in all cases: Ctrl/Scroll-click a link and the history is cleared, but Ctrl/Scroll-click the Back button and your history get copied. – CodeCaster Oct 15 '13 at 14:42
-
@CodeCaster No it doesn't. If you're opening a link in a new tab then there is no history. Try it on this page, using Chrome. I just did :) – Reinstate Monica Cellio Oct 15 '13 at 14:43
-
but if the user is already using the tab for another websites, then that will have the history. then what to do? – Nav Purewal Oct 15 '13 at 14:54
-
This will tell you if the user has gone to the home page in an existing tab, or a new tab. – Reinstate Monica Cellio Oct 15 '13 at 14:55