Click to See Complete Forum and Search --> : Window.open for POST method


ritukhetan
01-02-2003, 06:54 AM
Hello all,


How can I have a new pop up opening up using window.open() while using POST method in an HTML form.

Here is a sample function I have tried. Here I want to show the result of the program in the new pop up whose size and other attributes can be controlled by me. Using "_new" is not accepatable.

function doscratch_mail(){
fh = document.scratchpad;
// fh.action= "/dgtlbin/scratch_mail";
window.open("/dgtlbin/scratch_mail","scratch_mail","toolbar=0,status=0,scrollbars=1,location=0,width=490,height=415,resizable=0");
//fh.target= "_new";
fh.method = "POST";
fh.submit();

return false;
}

Hoping to get a quick response, as I desperately need a solution to this.

Regards,
Ritu

swon
01-02-2003, 07:15 AM
It's easier to use the form tag instead of a function.

<FORM name=form onsubmit="javascript:window.open('','fenster','width=400,height=500,scrollbars=yes')" action="YourActionFile.html" method="post" target="fenster">

let me know if it's not what you want.

Charles
01-02-2003, 09:49 AM
Originally posted by swon
<FORM name=form onsubmit="javascript:window.open('','fenster','width=400,height=500,scrollbars=yes')" action="YourActionFile.html" method="post" target="fenster"> should be:

<FORM name=form onsubmit="window.open('','fenster','width=400,height=500,scrollbars=yes')" action="YourActionFile.html" method="post" target="fenster">

hester1645
04-25-2008, 03:45 PM
javascript solution:
function openWindowWithPost(url,name,keys,values)
{
var newWindow = window.open(url, name);
if (!newWindow) return false;
var html = "";
html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";
if (keys && values && (keys.length == values.length))
for (var i=0; i < keys.length; i++)
html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";
html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</script></body></html>";
newWindow.document.write(html);
return newWindow;
}

works in IE and firefox