javascript 如何在 iframe 内发送表单?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5132596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 16:04:47  来源:igfitidea点击:

How can a form be sent inside iframe?

javascripthtmlformspostiframe

提问by Yunus Eren Güzel

I want to send a formto inside an iframe. How can i do this?

我想form在一个iframe. 我怎样才能做到这一点?

回答by sgokhales

The targetattribute of form tag specifies where to open the action URL.

targetform 标签的属性指定打开操作 URL 的位置。

You can do like following :

您可以执行以下操作:

<iframe name="myframe" id="frame1" src="mydetail.asp"></iframe>
<form action="../mydetail.asp" method="post" target="myframe">
<input type="submit" name="DoIt" value="DoIt">
</form>    

The targetattribute is used with frames to specify the frame in which the form response should be rendered. If no frame with such a name exists, the response is rendered in a new window unless overridden by the user.

target属性与框架一起使用以指定应呈现表单响应的框架。如果不存在具有此类名称的框架,则除非被用户覆盖,否则将在新窗口中呈现响应。

回答by Pekka

Using the targetattribute.

使用target属性。

<iframe name="my_iframe" src="..."></iframe>

<form action="...." target="my_iframe">