Home | All Questions | alt.html FAQ > HTML Forms

How do I submit a form and have the results returned in a new window?

In HTML, you can at most specify (or, rather, suggest) with the target attribute in the <form> tag that the results appear in a new window; you can't specify the properties of such a window in HTML.

The properties could be specified in JavaScript code, which may or may not be executed by the browser.

Combining these, you could write e.g.

<form action="/cgi-bin/foo.pl"
target="foo" onsubmit="window.open('','foo',
'resizable=1,scrollbars=1,width=400,height=300')">

Strictly speaking, this doesn't create a new window upon each submission. If the form is submitted several times, the first submission creates the window but then that window is reused. This is probably better than creating a window for each submission. (Implementing the latter is more complicated.)

Recommended Resources

Discussion

Related Questions