Best Practice in Handling Multiple Browser Windows and/or Tabs
What is the best practice in handling multiple windows and/or tabs in a web application? What are the pros and cons of a given approach?
I'm not looking for an answer that specifies a particular framework solution. The best practice should apply to all HTTP/HTML based web applications whether they are ASP, .NET, Java Servlets, Struts, JSF, etc
Assumptions:
the application cannot prevent a user from opening a new window and/or tab
HTTP / HTML (how or if it is generated by some framework should not matter). Not Flex, Flash, etc
Should the app try to detect (possibly v开发者_运维知识库ia a nonce or other technique) that a new window and/or tab has been opened and display some error message?
If the app allows a new window and/or tab, what are the pitfalls (form submissions for one) to watch for and how should they be handled?
I'd say the biggest thing is avoid using "long-persisting" mutable session data (Data that will be hanging around longer than just the instance needed to transfer the data to the next page). This is the biggest challenge I've seen with multiple tabs. What I like to do is store data in the session and then "serialize" that data into the page. When I need that data again I grab it from the page and then store it in the session. That prevents the users other open pages from changing the data.
Your application shouldn't care about multiple tabs being opened. The tab paradigm was developed with the assumption that a page is a page. The biggest thing to do is to understand the technology you are implementing the page in(where there is a potential for data being shared at a global level) and building your pages to be thread-safe(because technically speaking every page request is a thread).
精彩评论