Avatar of Aleks
Flag 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 ?
ASPWeb DevelopmentHTML

Avatar of undefined
Last Comment

8/22/2022 - Mon

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.

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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck

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.

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.

Thanks you. This might be useful. I will read it tomorrow.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

If there form/data collection spans 20 pages, presumably each stage is saved, while the data is built-up.............

Handling of the data collection............

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.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

We are trying a different approach.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy