var f = document.forms['myform'];
is both sufficient and downwards compatible. One probably want to add
if (f)
{}
*if* that approach would work (which it does not).
.....Thanks for your reply. How should I call this function in the
form??
You don't, since it does not work this way. The `target' attribute value
is of type string, not an object reference that window.opener returns.
What may work is
if (f && window.opener && !window.opener.closed)
{
window.opener.name = "foo";
f.target = "foo";
}
No, it definitely should not and will not.
function update_parent()
{
window.opener.reload();
window.close();
}
window.opener.location.reload(), which is probably what you were
looking for, only reloads the opener document. It does not transmit
information newly input by the user.
<form name="myform" action="run.php" method="get"
onSubmit="javascript:update_parent()">
Proprietary `javascript:' URIs do not belong into attribute values for
intrinsic event handlers (as recent discussions have shown, they seldom
belong anywhere). So `javascript:' is but a label here, used only by
the MS script engine. Remove the labels and, for user agents who support
it, properly declare the default scripting language via a `meta' child
element of the `head' element:
This runs the PHP script but displays the results in popup page (not in
opener
BAD. B0rken as designed.
and didn't close the popup window as expected).
Because there is no such intrinsic method as window.opener.reload() in any
AOM (Application Object Model) I know. You received a script runtime error
when trying to call it, but you either overlooked or ignored that.
function update_parent2(url)
{
window.opener.location.href=url;
window.close();
}
<form name="myform" action="run.php" method="get"
onSubmit="javascript:update_parent2('run.php')">
That will not transmit any new data either. You probably notice that
pure fantasy syntax such as this seldom returns a viable result. Get
yourself some decent documentations on HTML, JS, AOM/DOM (there are
plenty on the Net, for free) and develop according to them. See
<
http://jibbering.com/faq/>.
<FAQENTRY>
- In section 3.2, the FAQ still refers to
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/
which is dead since almost a year:
<
http://www.mozillazine.org/talkback.html?article=5381>
It should point to a mirror like
<
http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/reference/>
- Not mentioned in the FAQ, there was also a documentation on JavaScript 1.5
available on DevEdge, which is now hosted at the Mozilla Foundation
website:
<
http://developer.mozilla.org/en/docs/JavaScript>
- General information on JavaScript, the ECMAScript 3 Final Specification
and previous editions can be found at
<
http://www.mozilla.org/js/>
and
<
http://www.mozilla.org/js/language/>
- W3C DOM Level 1 HTML has been obsoleted by W3C DOM Level 2 HTML (see:
"Status of this document" section), yet the FAQ refers to the former's
ECMAScript Language Binding section. It should refer to
<
http://www.w3.org/TR/DOM-Level-2-HTML/ecma-script-binding.html>
instead.
- The FAQ does not contain any reference to any W3C DOM Level 3
specification:
<
http://www.w3.org/DOM/>
The javascript works fine but doesn't actually run the PHP script as
expected. I mean, the "update_parent2" replaces the main window with
specified url and closes the popup window but the user (checkbox) input
in popup form is not being used.
As I wrote, it's just BAD.
Any more pointers would be helpful.
[x] done
HTH
PointedEars