如何将HTML表单提交到禁用了大小调整的Popup窗口? [英] How do I submit an HTML form to a Popup windows with resize disabled?

查看:87
本文介绍了如何将HTML表单提交到禁用了大小调整的Popup窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用提交按钮设计了一个HTML表单。但不是提交到另一个页面,我想提交弹出窗口,我可以限制弹出窗口的大小,如320x240隐藏所有工具栏,禁用调整大小。

解决方案

这是我的工作,这个JavaScript代码片段应该放到页面的头部:

 < script> 
process = function()
{
window.open('about:blank','popup','width = 320,height = 240,resizeable = no');
document.login.setAttribute('target','popup');
document.login.setAttribute('onsubmit','');
document.login.submit();
};
< / script>

这是一个用于演示目的的示例表单:

 < form action =handle.htmlmethod =getname =loginonsubmit =process(); return false;> 
用户名:< input type =textname =usernameid =username/>< br />
< input type =submit/>
< / form>

现在,发生了什么事情:首先,我们建立一个表单并给它一个 onsubmit 属性,告诉它运行函数 process()返回false; 而不是正常提交​​;从这一点开始,该函数接管并创建一个弹出窗口,给它一个名称和一些特征(通过一切手段,添加任何你想要的多余特征),然后注意力返回到表单,我们现在设置 target 属性添加到我们刚刚创建的窗口的名称中。

然后我们必须清除 onsubmit ,或者同样的事情会再次发生,这当然不是你想要的。最后,我们再次提交表单,现在它将所有信息传递给弹出的窗口;从那里开始,它只是获取 handle.html (或者最终调用处理页面的任何内容)来完成它对数据的工作。



希望我帮了忙。


I had designed an HTML form with submit button. But instead of submit it to another page I want to submit to pop up windows where I can limit the size of the pop up windows say "320x240" hide all the toolbar, disable resize.

解决方案

Here's my go at it; this JavaScript snippet should go into the head of your page:

<script>
process = function()
 {
    window.open('about:blank', 'popup', 'width=320,height=240,resizeable=no');
    document.login.setAttribute('target', 'popup');
    document.login.setAttribute('onsubmit', '');
    document.login.submit();
 };
</script>

And this is a sample form for demonstration purposes:

<form action="handle.html" method="get" name="login" onsubmit="process(); return false;">
Username: <input type="text" name="username" id="username" /><br />
<input type="submit" />
</form>

Now, here's what's happening: first, we set up a form and give it an onsubmit attribute that tells it to run the function process() and return false; instead of submitting normally; from this point, that function takes over and creates a popup window, giving it a name, and some features (by all means, add any surplus ones you'd like), and then attention comes back to the form, where we now set the target attribute to the name of the window we just created.

We then have to clear that onsubmit that we set earlier, or this same exact thing will happen again, and that's certainly not what you want. Finally, we just have the form submitted again and it now passes all of its information to the popped window; from there, it's just getting handle.html (or whatever you end up calling your processing page) to do its work with the data.

Hope I've helped.

这篇关于如何将HTML表单提交到禁用了大小调整的Popup窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆