Reload parent window with parameters from within Javascript

I have a minor problem that I am having issues with.  After a child window has been submitted I would like to have the parent window reload with parameters.  Is this possible?

This is an urgent matter so please also provide an example
ralphsautoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pravin AsarPrincipal Systems EngineerCommented:
Here is an example



parent.htm

<html>
<head>
<title>Parent Document</title>
</head>

<body>
<script language="javascript">
      window.open ("child.htm");
</script>
</body>
</html>

child.htm

<html>
<head>
<title>Child Document</title>
</head>

<body>
<form method="get" target="MyParent" action="parent.htm" onSubmit="window.opener.name='MyParent', window.setTimeout(function () { self.close(); }, 1000);"><input name="name" value="Default">
<input type="submit" name="submit">
</form>
</body>
</html>
ZvonkoSystems architectCommented:
Reloading the parent window on submit is easy as this:
<form name="yourForm" action="yourcgi.asp"  onSubmit="opener.location.reload(true)">


But that has a smal trap. Because you reload the parent on child form submit, is the server side not updated by the submit data and the reload of the parent does not reflect the submited state.
So the better choice is to do regular submit of the child form and responde this from your server page accepting the submit (I mean yourcgi.asp ):
<script>opener.location.reload(true);self.close();</script>

That two statements is all what the submit response need, and the parent will be refreshed and child closed, after the submit response arivel.

ralphsautoAuthor Commented:
Both of you have good ideas, but first point is the child should not be closed as the submit is setting up for printing.  

Zvonko, I think that you have a better plan, simple is always good.  two things:

1: I already have a javascript page being loaded so I would use a reference to a function but thankfully no onsubmit function
2: The child window needs to submit the contents of the form then when it reloads the parent gets refreshed so maybe it should be  on the onload event?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

ralphsautoAuthor Commented:
No the parent doesn't need to be updated as the relevant information is stored in a cookie.
ZvonkoSystems architectCommented:
OK.
And for the onLoad question: no, it needs not to be in onLoad event handler. Every <script> is executed wherever it is located on the page.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Pravin AsarPrincipal Systems EngineerCommented:
My posted example assumed

1. You  do not want to have child form any more. Submitting the child to parent window and leaving the child window
   open may be confusing. As user is waiting for the current window to update.
2. If you do not want, do not close. It is upto you.
ralphsautoAuthor Commented:
Ok Zvonko your little script works the way I want it to except that it asks to repost the form data, can one cancel that so that it doesn't ask just reloads the page without the old form data?
ZvonkoSystems architectCommented:
Try this:

<script>opener.location.replace(opener.location.href)</script>

ralphsautoAuthor Commented:
How would I add Parmeters to the href even if I add it after a ?

is there a href = self?param1=56&param2=65

ZvonkoSystems architectCommented:
Like this:

<script>opener.location.replace(opener.location.href+((opener.location.search)?"&":"?")+"param3=33")</script>



It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.