[英]Reloading parent window with a button in the iframe
I have an iframe in a page like 我在页面中有一个iframe
<iframe src="something.html"></iframe>
and in the something.html page, I have a form and a button. 在something.html页面中,我有一个表单和一个按钮。
<form action="anywhere.html">
<input type="button" name="submit" value="submit">
</form>
When I click on the submit button, it only reloads the page anywhere.html (inside the iframe). 当我点击提交按钮时,它只会重新加载任何地方的页面(在iframe内)。 But I want anywhere.html to load in the same main window (not in a new tab or window or not in the iframe).
但我希望anywhere.html加载到同一个主窗口(不是在新的选项卡或窗口中,也不在iframe中)。 How can this be done?
如何才能做到这一点?
Use the target attribute for the form tag. 使用表单标记的target属性。 Set it to _parent to have the form submit to the parent window (outside the frame).
将其设置为_parent以将表单提交到父窗口(框架外)。
<form action="anywhere.html" target="_parent">
<input type="button" name="submit" value="submit">
</form>
See it demonstrated in this plunker . 看到它在这个plunker中演示。
1 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-target 1 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-target
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.