网上搜索到方法:
function openSpecfiyWindown( windowName ) {
window.open('about:blank',windowName,'width=700,height=400,menubar=no,scrollbars=no');
}
< form id = "editForm" name = "editForm" method = "post" action = "viewUser" target = "colors123" onsubmit = "openSpecfiyWindown( 'colors123' )" >
< fieldset >
< input type = "hidden" id = "id" name = "id" value = "$!{User.id}" />
< input type = "submit" />
</ fieldset >
</ form >
想用JS实现,更方便:
<script>
function submit_detail(code)
{
var keys=['date1','date2','time1','time2'];
var values=['${oForm.date1}','${oForm.date2}','${oForm.time1}','${oForm.time2}'];
openWindowWithPost("/test.do",'newwindow',keys,values);
}
function openWindowWithPost(url,name,keys,values)
{
var oForm = document.createElement("form");
oForm.id="testid";
oForm.method="post";
oForm.action=url;
oForm.target="test123";
if (keys && values && (keys.length == values.length))
{
for (var i=0; i < keys.length; i++)
{
var oInput = document.createElement("input");
oInput.type="text";
oInput.name=keys[i];
oInput.value=values[i];
oForm.appendChild(oInput);
}
}
oForm.onSubmit=function(){openSpecfiyWindown(name)};
document.body.appendChild(oForm);
oForm.submit(); //这个和手动点击提交不是一回事
}
//触发不动这个函数,实在没办法
function openSpecfiyWindown(name)
{
// alert(name);
window.open('about:blank',name,'height=1024, width=1280, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
}
</script>
如何截获事件呢? 哪位知道麻烦告诉一声。