Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 222049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:05:27+00:00 2026-05-11T19:05:27+00:00

The users of my web application may have more than one browser window open

  • 0

The users of my web application may have more than one browser window open and pointed to the same page. I would like the state of certain things in the page (loaded via ajax) to be retained across postbacks. I can either store in a cookie or on my server. Either way, I can’t think of how I can distinguish each window.

For example, say user Bob has two browser windows open to the ListOfSomething page. Each list has a LoadedPageNumber attribute which I need to persist. Otherwise users always end up on page 1 when they refresh. Bob might have loaded browser window 1 and pointed it to page 5 and then loaded browser window 2 and pointed it to page 14. If I just store the attribute based on session id, Bob will get page 14 in window 1 if he refreshes it.

Note that my state variables are actually much more complex than this simple example and my inability to persist them could lead to big problems (weaknesses in my app).

I need some kind of browser window id or something. It of course needs to be a cross-browser solution (IE6+, Wekbit?+, FF2+)

Any ideas?

Note on relevance: Keep in mind that this is useful also for the case where you’re mixing older forms based pages with newer AJAX enabled items. Sometimes you need to postback the forms and you don’t want to loose some client side state values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:05:27+00:00Added an answer on May 11, 2026 at 7:05 pm

    you could set your own window name, the exact syntax escapes me right now, but you can use the current time and session id to create a unique id on window load, then use that id

    This would be done the same way you set a name in the javascript window.open() function, (but you can do it to self, instead of new window)

    googling shows:

    self.window.name = myclass.getUniqueWindowId( thisSession );

    UPDATE

    Regarding your need to save this from refresh to refresh, i did some tests and it looks to save it from refresh to refresh. Using Firefox 3, on initial load, the window name is blank, and pressing CTRL+R over and over, and the window name was populated. i then commented out the setting the name code and reloaded and it still retained the name.

    <script type="text/javascript">
    
        alert( self.window.name );
    
        self.window.name = "blah";
    
    </script>
    

    UPDATE

    I have to make noticed the comment below on jQuery’s ‘jquery-session’ plugin, which really works and offers way more than what’s discussed here.

    Although, one should also make it clear that it relies on HTML5’s Web Storage, not supported by older IE versions.

    Corporate still depends heavily on IE 7 (‘and below’ here in Brazil).

    Based on self.window.name, THE solution for everything non-compliant to HTML5, I offer the following code snippet as a cross-browser solution:

    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/jscript">
        //----------------------------------------------------------------------
        //-- guarantees that window.name is a GUID, and that it would
        //-- be preserved whilst this window's life cicle
        //----------------------------------------------------------------------
        //-- window.name will be set to "GUID-<SOME_RANDOM_GUID>"
        //----------------------------------------------------------------------
    
        $(window).load(
            function () {
                //----------------------
                var GUID = function () {
                    //------------------
                    var S4 = function () {
                        return(
                                Math.floor(
                                        Math.random() * 0x10000 /* 65536 */
                                    ).toString(16)
                            );
                    };
                    //------------------
    
                    return (
                            S4() + S4() + "-" +
                            S4() + "-" +
                            S4() + "-" +
                            S4() + "-" +
                            S4() + S4() + S4()
                        );
                };
                //----------------------
    
                if (!window.name.match(/^GUID-/)) {
                    window.name = "GUID-" + GUID();
                }
            }
        ) //--------------------------------------------------------------------
    </script>
    

    I found the GUID function here (for which I proposed some code clean-up).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 244k
  • Answers 244k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer function newTextBox(element) { instance++; // Create new input field var… May 13, 2026 at 7:58 am
  • Editorial Team
    Editorial Team added an answer import urllib import re fbhandle = urllib.urlopen('http://www.facebook.com/Microsoft') pattern = "6… May 13, 2026 at 7:58 am
  • Editorial Team
    Editorial Team added an answer x.herotype = HeroType.Agility; is normally the code to set it.… May 13, 2026 at 7:58 am

Related Questions

I want my application to fill in a single field in a form that
I am developing a Java web application that bases it behavior through large XML
I have a static object defined in my logging class, along the lines of:
I'd like to implement a way to display a list of stored addresses sorted

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.