in reply to Re: Finding out Browser History Length
in thread Finding out Browser History Length

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
  • Comment on Re^2: Finding out Browser History Length

Replies are listed 'Best First'.
Re^3: Finding out Browser History Length
by Joost (Canon) on Aug 16, 2007 at 17:37 UTC
    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.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^3: Finding out Browser History Length
by blazar (Canon) on Aug 17, 2007 at 16:18 UTC
    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.

      by new i meant that the window opened up does not have any history before that. if a link is opened in a new window then that window is called new. if it is opened in the same window as the current page, the window is called as old.

        Well, then the history is a client side thingie. It can be accessed through a client side language, like JavaScript. Then you can use JavaScript itself to modify the page on the fly or, if you want the job to be done on the server you can have it say post some relevant info upon which the server will serve a suitable page. Or else you may have the client communicate with the server with AJAX techniques. That's pretty much everything that's to it. But then again... I for one would find your site's behaviour to be very annoying: I often right-click-open-in-new-tab links instead of plain clicking them. Why should the page I get to be different across the two cases?