Submit form to new window or parent window - compatable with FF & IE?

As per the title ...
My situation is, user of site clicks on "Login" from any of the main public pages, which opens a small popup to grab the User Id & Password, when they submit I (read the Boss) wants it to either:
a) Open a NEW window which logs in & displays user's control page.
b) Login & display control panel on the ORIGINAL page, where the usr clicked "Login"
In both cases, the little popup login window is to close.

I thought this would be simple - probably just overlooked something.

With a)
IE works fine. Firefox opens the new window as a TAB inside the teensy weensy login popup :|
Tried creating new window and used both window handle and window name as the target with no luck, still in a tab, and IE opens a blank window PLUS a windowto which it submits the form.

With b)
Neither browser seems to recognize the parent as a target for the form.
Tried "target" = _blank, _new, _parent, _top
Tried javascript "onsubmit" passing the form ('this') as argument to a function, into a variable 'f'.
With that, I've tried f.target=window.opener; f.target=window.opener.name;

What am I missing?

My basic logic "attached as code snippet" so not sure where it appears, but it's here somewhere.

Thanks a bundle :)

<html>
	<head>
		<script language="javascript" type="text/javascript">
 
			function checkForm ( f )
			{
				if ( checkLogin() )
				{
					f.target = window.opener.name;
					//f.target = window.opener;
					//f.target = parent;
					f.submit();
					self.close();
				}
				else
				{
					return false;
				}
			}
	        </script>
	</head>
	<body>
		<form action="%server_url%/cgi-bin/_front/services.cgi" method="POST" name="loginForm"
			id="loginFormID" onsubmit="return checkForm( this )" target="_new">
			<!-- tried above: target="_new" target="_blank" target="_parent" target="_top" etc. -->
 
			<input type="hidden" name="action" value="login" />
 
			UID: <input type="text" name="uid" /> <br />
			PASS: <input type="text" name="pin" /> <br />
			<input type="submit" name="submit" value="LOGIN" />
 
		</form>
	</body>
</html>

Open in new window

LVL 1
GlauronAsked:
Who is Participating?
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.

GlauronAuthor Commented:
"Tried creating new window and used both window handle and window name as the target with no luck."

I'll expand on that...
Note, the timeouts were an attempt to stop IE from opening a blank window, AND a second window with the page I wanted.
			function checkForm ( f )
			{
				if ( checkLogin() )
				{
					var myWin = window.open('', 'controlPage');
					setTimeout("f.target = 'controlPage';", 250);
					setTimeout("f.submit();", 350);
					setTimeout("self.close()", 500);
					//f.submit();
					//self.close();
				}
				else
				{
					return false;
				}
			}

Open in new window

0
Michel PlungjanIT ExpertCommented:
you should never submit in the submit event

function checkForm ( f ) {
  if ( checkLogin() ) {
    f.target = window.opener.name;
    setTimeout('window.close()',200);
    return true; // allow the submit
  }
  return false;
}
0
Michel PlungjanIT ExpertCommented:
or

function checkForm ( f ) {
  if ( checkLogin() ) {
    var myWin = window.open('', 'controlPage');
    f.target = 'controlPage'; //  if the above  fails, the target will still open a new window
    setTimeout("self.close()", 500);
    return true; // allow submit
  }
  return false;
}
0
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.

Michel PlungjanIT ExpertCommented:
I am assuming your checkLogin does nothing strange and works and exists
0
GlauronAuthor Commented:
Yes checkLogin exists, and does nothing more than check form values & show "alerts" / "confirms" if it finds something wrong. Returns true/false (false if problems in form).

I've actually figured out what I was doing wrong, and it was a simple little thing like I had imagined ...
I got it working with existing code just by running
window.name = 'windowABC123';
in some JS on the opening window, so the child window actually had a name to reference. I guess I though the browsers would supply a default window name or some such. :/

Thanks for the tip re: invoking the submit event. Knowing best practices is always a plus.
0
Michel PlungjanIT ExpertCommented:
Riiight... I saw the window.opener.name and of course assumed you had coded that already :))
0
Computer101Commented:
PAQed with points refunded (125)

Computer101
EE Admin
0

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
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.