[thelist] Window targeting problem
Jeff
jeff at members.evolt.org
Mon, 17 Jan 2000 22:59:24 -0800
keith,
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Keith Davis <cache@dowebs.com>
:
: Opening into the same window from a form submit is really a lot simpler
: than you try to make it. The important thing is to guarantee that the
: window is opened and given an HTML window hierarchy name on each submit
: BEFORE the form is submitted. This cannot be accomplished with the
: onsubmit method since the window.open occurs AFTER the submission has
: taken place and returned a true condition.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
this is simply not true. if it were true, then how would we use the
onSubmit handler to validate forms prior to sending? in actuality, onSubmit
does just what it sounds like, it fires upon submission of the form, and
subsequently can be used to halt the submission as well.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: <a href="javascript:openWin()">image here</a>
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
i don't advocate this because you'll be immediately eliminating all non-js
users from using your form.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: IMHO, if you are not doing any read/write from the
: parent, don't mucky things up with the variable as it has no function.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
the variable name is necessary for doing things like setting the window's
focus, which is necessary in ie4/5 as this browser has problems focusing a
targeted window.
the bulletproof code i've been using is below. it's important to note that
the name of the window and the value of the target attribute of the <form>
tag match. it's also important to note that we're calling the function that
opens the window with the onSubmit handler of the <form> tag and requesting
that the function return true or false before completing submission. this
way we can open the window, returning true and then submit the form which
will get targeted to the popup.
in the head of your document:
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function openWin(wName)
{
popWin = window.open('',wName,'width=400,height=300');
return true;
}
// -->
</SCRIPT>
and call it like this:
<FORM
ACTION="process.html"
METHOD="get"
TARGET="newWin"
onSubmit="return openWin('newWin')">
this has the advantage of working equally well for js and non-js browsers.
the only difference is the js browser will have a javascript opened window
and the non-js will have a standard targeted window.
if necessary i can put up an example of this for people to test out.
thanks,
: jeff.howden
: web.development.professional
: evolt.org.member
:
: the.best.looking.developers.on.the.net
:
: http://evolt.org/
: jeff@members.evolt.org