Link to home
Create AccountLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

Close browser window and redirect

I have a page that opens a browser window, it displays a form that the user fills out.  When the user finishes they simply click the upper right corner of the window to close it. The problem is when they do that I need for the main page which has the link to open it to REFRESH. Because when they save the form displayed in the pop up an entry is made in the database and if they want to open it again the main page needs to be refreshed to pass on the new parameter.

How can I close the pop up window AND refresh my main page when they do ?
Avatar of arnold
arnold
Flag of United States of America image

Do you use Ajax/Jason?
Does your form page include a submit which you can use to record the data, close the window (some will be promoted to confirm) and in change the main page will refresh.
Avatar of Aleks

ASKER

The forms code is generated by a provider, so I cannot touch it. We can however configure adding buttons. I can add a button with javascript that would close the window and then refresh the parent window.
IF I do this I need to take out the "X" close button of the browser window, otherwise user might click on that and adding a button has no purpose.
my guess the user hits close, because there is no other option there.
You could add JavaScript validation that triggers the submit when all the form fields are filled in. I.e. Each field onChange trigger a check to see whether the form is complete. Providing the user with a submit button will remove the need of the user closing the window by them selves. Also when you open a separate window, your main page could keep /detect the event when the window is closed.
Avatar of Aleks

ASKER

That wouldn't work. Saving the form doesn't mean the user is done with the form, forms can be 20 pages long so they fill one page or a few fields and then save it.
when they CLOSE the form then that is when it should close and refresh the parent page.
You can look at the example dealing with opening a new window while handling the close event.

http://www.javascript-coder.com/window-popup/javascript-window-open.phtml
The examples pops a notice to the user, a similar mechanism could be a response to the parent page who opened the window to refresh.

The open window you will have onSubmit do things, then window.close.
.

Test out a parent that opens a window, then displays the window closed in the parent window.
Avatar of Aleks

ASKER

Thanks you. This might be useful. I will read it tomorrow.
If there form/data collection spans 20 pages, presumably each stage is saved, while the data is built-up.............

Handling of the data collection............
Avatar of Aleks

ASKER

nop. they save whenever they want. they could save after entering two fields or 10, its up to the user to decide when they want to save their work.
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Aleks

ASKER

We are trying a different approach.