First, below code will achieve what you're looking for in question one and
two (answer to question three below the code).
<html>
<head>
<title>oNewWin</title>
<script language="JavaScript" type="text/javascript">
<!--
function openWin(){
window.open("formNewWin.htm", "oNewWin",
"left=0,top=0,width=400,height=200,toolbar=no");
}
//-->
</script>
</head>
<body>
<form onSubmit="openWin()" method="GET" target="oNewWin">
<input type="text" name="field1"><br>
<input type="text" name="field2"><br>
<input type="submit" value="Send">
</form>
</body>
</html>
To answer question three, insert a link that looks like this:
<a href="#" onClick="window.close(); window.opener.location.reload()">Close
window</a> or
<a href="#" onClick="window.close();
window.opener.location.replace('index.htm')">Close window</a> or
/Robert
-----Original Message-----
From: Laphan [mailto:laphan@u...]
Sent: den 29 oktober 2001 02:17
To: javascript
Subject: [javascript] Submitting FORM data into a new window
Hi All
Can somebody please give me some code to do the following:
1) I want to click a text link on 1 web page to send form data to a web page
in a brand new window.
2) This brand new window wants to be in the top left corner of the screen,
minus various features (eg, toolbar=no) and wants to be a fixed size.
3) Once they have done what they need to do in the brand new window, I then
want a text link on this window to close the brand new window AND
change/referesh the orignal window so that it goes back to the beginning, eg
the location = index.html.
I know simply by putting TARGET="_blank" in the original window's FORM tag
will open a brand new window, but I want to be able to format it as per
point 2.
I have the following bits of code set up, but in some browsers it opens up
the required window with no form data on it and then seconds later opens up
another 'unformatted' window with the form data on it.
My code bits are as follows:
ORIGINAL WINDOW
===============
FORM says: <FORM NAME="form1" ACTION="order-process.asp" METHOD="POST"
TARGET="order">
Text link says: <A HREF='javascript:void(0)'" OnClick='AnyOrder();return
false'>Process this</A>
AnyOrder() says:
ShowSSL();
document.form1.submit();
return true;
ShowSSL says:
var
features='toolbar=0,location=1,directories=0,status=1,menubar=0,scrollbars=1
,resizable=0';
var url = 'process.asp';
var winName = 'order';
var win;
if (win && !win.closed) {
win.focus();
return false;
}
else {
win
window.open(url,winName,'width=610,height=400,screenX=0,screenY=0,top=0,left
=0,'+features);
if (!win.opener) win.opener = self;
return false;
}
NEW WINDOW
===========
Text Link says: <A HREF="javascript:CompleteOrder()">here</A>
CompleteOrder() says:
opener.top.location.href = 'default.htm';
opener.win.close();
Can anybody help?
Rgds
Laphan
laphan@u...