faqts : Computers : Programming : Languages : JavaScript : Forms

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

296 of 352 people (84%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

How to submit a FORM to a new window with certain features set?

Feb 13th, 2000 06:53
Martin Honnen,


You can submit a FORM to a new window with
  <FORM TARGET="_blank" ...>
but that newly opened window has the standard dimensions and features. 
If you want to set the features of the window then use the onsubmit 
handler to open a window with a certain name and the desired features 
first, then set the FORM's TARGET to the window name before submitting 
the FORM:

<SCRIPT>
function openTarget (form, features, windowName) {
  if (!windowName)
    windowName = 'formTarget' + (new Date().getTime());
  form.target = windowName;
  open ('', windowName, features);
}
</SCRIPT>


<FORM ACTION="whatever"
      ONSUBMIT="openTarget
(this, 'width=300,height=300,resizable=1,scrollbars=1'); return true;"
>

The openTarget function needs at least two arguments, without the third 
it always opens a new window (like target _blank) but you can provide a 
third argument for the window name to reuse the window later.