Detect if a form POST browser window is open in Javascript?

I have a form post method, which is used to show a new page. Its done this way so that the arguments used cannot be seen in the location bar.

Each window is given a unique name, but I want to be able to detect if this browser window is already open, so that calling this form again will not force that current browser window to auto-fresh.

Any suggestions?

Answers


I assume you're opening new windows in Javascript. So, assign a variable name to your new window (e.g. var newWin1 = window.open(...))

Then test to see if the document of your window exists:

if(newWin1.document) { alert("Window is open!"); }
else { alert("Window is gone!"); }

For a security note: people can still see the post data you're sending with any HTTP header tool. Check out LiveHTTPHeaders for Firefox (or a million others) to see what I mean.

Another note: Not sure what you're doing, but people don't like when a webpage does things without them asking it to (like opening windows). You may want to consider improving your design to a more user-friendly method.


Need Your Help

JSF. Convert value for h:commandLink display

jsf jsf-2

I am passing Status object to h:commandLink value. So it is displayed on the page. The problem is, displayed string is

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.