按下预览按钮时,jquery/javascript发布到新窗口 [英] jquery/javascript post to new window when pressing a preview button
本文介绍了按下预览按钮时,jquery/javascript发布到新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个带有两个按钮的表单,即提交&预览,预览按钮应打开一个新窗口,其中包含来自输入区域的文本.我该如何做到这一点?
I want to have a form with two buttons, submit & preview, the preview button should open a new window with the text from the input areas how do I make that happend?
<form method='post'>
//input
<input type='text' name='headline' id='headline' />
<textarea name='content' id='content'></textarea>
//buttons
<input type='submit' id='btnsubmit' value='submit' />
<input type='submit' id='btnpreview' value='preview' />
</form>
我无法在形式上使用target'_blank',因为我有两个按钮,并且只有一个应该在新窗口中打开,我希望在jquery中完成此操作.有人可以帮忙吗?
I can't have target'_blank' in form because i have two buttons, and only one should open in a new window, i would like this to be done in jquery. can someone help.
推荐答案
如果要将表单发布到新窗口,则需要设置表单的目标.您可以为每个按钮设置目标:
If you want to post the form to a new window, you need to set the target of the form. You can set the target for each button:
$(function(){
$('#btnsubmit').click(function(){
this.form.target = '';
});
$('#btnpreview').click(function(){
this.form.target = '_blank';
});
});
这篇关于按下预览按钮时,jquery/javascript发布到新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文