Contact Us

 Admin User     Feb,08 2017

Submit Form To A New Window, With window.open() Features

To submit form to new window, we set the target attrubutes to '_blank'. But we can't set the new window's property such as height, width etc. So to submit the form to new window with 'window.open()' features, Let's look at the below code.

 <html><head><script type="text/javascript">function submitForm(){document.form1.target = "myActionWin";window.open("","myActionWin","width=500,height=300,toolbar=0");document.form1.submit();}</script></head><body><form name="form1" action="demo_action.cfm" method="post">First name: <input type="text" name="fname" /><br />Last name: <input type="text" name="lname" /><br /><input type="button" name="btnSubmit" value="Submit" onclick="submitForm()" /></form></body></html> 

First of all I set the target attribute of my form (form1) to 'myActionWin' which is the name of the target window (or can be the target frame). Then Open the new window having the name 'myActionWin' and set the window property whatever you want with the window.open. And Lastly submit the form.

Demo