开发者

open form in new popup window of small size [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_如何转开发

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 1 year ago.

Improve this question

I want to open new url as a popup window on form submission. Can you please help me .


The FORM tag allows an onSubmit event handler which you can process JavaScript in.

You could do something like

<form ... onsubmit="return submitWindow">
</form>

And the JavaScript for opening the window

<script>
    function submitWindow() {
        ..
        // URL, name and attributes
        window.open('http://www.stackoverflow.com','windowNew','width=300, height=300');
        return true;
    }

Have a look at for more information on onSubmit: http://www.htmlcodetutorial.com/forms/_FORM_onSubmit.html

You could also add the window.open on your submit button using the onClick event.


source

function open_win(url_add)
   {
   window.open(url_add,'welcome',
   'width=300,height=200,menubar=yes,status=yes,
   location=yes,toolbar=yes,scrollbars=yes');
   }
<form onsubmit="open_win('http://url')" ...>

If you want to submit the form depending popup open, then you must return true/false from the respective function(here open_win(url_add)). And you have to use the return keyword on submit attr like - onsubmit="return open_win('url')


use target attribute for form

<form ... onsubmit="return submitWindow" target="_new">



</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜