You can't directly. You can use javascript, as you noted, or you can use a session or tracking cookie to see the "click-path" though your site, but that won't give you the same information, since the history length in javascript will give you the total number of pages in the current window while sessions will only give you the clicks for a specific domain.
Note that either way, you're relying on the browser not to lie to you.
update: ofcourse, you can use javascript to set a cookie containing the history length.
| [reply] |
Hi,
Thanks for your quick reply. Basically I am trying to use history.length to find out if the window is a current window or a new window. Basically i want to know if a link is opened in a new window on my site. So if history.length == 1 then it is new window else it is old window. If i set cookie, then how do i set window specific & not session specific cookie? is there any other work around to find if the browser window is new or old? By old i mean to say is that other links have already been visited on it.
Thank you,
Anant
| [reply] |
Hmm.. So you want to have the first click from any window that's just been opened to do something different than anything else?
You could modify (in javascript) all links on the page to add a parameter that sends that info over to the server side.
Normally, the server will not know or care which window is requesting what. That way, people can - for instance - copy the url from one window to the next without surprises. If you want to break that, you'd better have a good reason for doing so.
| [reply] |
is there any other work around to find if the browser window is new or old? By old i mean to say is that other links have already been visited on it.
What does that mean? Do you mean that a page is considered old if some of the links on it have been visited or if all of them have? In both cases this seems a different problem from the one you described in other posts. You should really try to describe what you're after more explicitly and in terms of UI, with no reference to the underlying technology - e.g.: "I want a user to click on a link and upon clicking this, that and that other thing must take place." Then I'm sure that people with experience in web development could successfully help you.
| [reply] |