简体   繁体   English

用户单击提交按钮时如何隐藏 iframe 表单

[英]How to hide a iframe form when users click on submit button

I have a google form iframe.我有一个谷歌表格 iframe。 I want to hide the iframe when users click on submit button.当用户单击提交按钮时,我想隐藏 iframe。 So the main content behind it can reveal.所以它背后的主要内容可以揭示。 Thanks.谢谢。

<h1>this is hidden content</h1>
<p>What is Lorem Ipsum?
Lorem Ipsum is simply dummy</p>
<div class="login">
<iframe name="target-iframe" src="https://docs.google.com/forms/d/e/1FAIpQLSc6XXOdWSJoHbfdUMRyOsVhap5r7-nR5nhdyWgZyOavYFz9bw/viewform?embedded=true" width="100%" height="100%" frameborder="0" marginheight="0" marginwidth="0">Loading…</iframe>
</div>

/* Add display:none to login class to hide the form */

.login {
    position: absolute;
  top: 0px;
  left: 0px;
  right: 0px;
  bottom: 0px;
    background-color: white;
}

iframe {
  display: block;
  max-width: 100%;
  margin: auto;
  height: 100vh;
  z-index: 2;
}

https://codepen.io/TianxuanL/pen/mdWmbBK https://codepen.io/TianxuanL/pen/mdWmbBK

Short story: you cannot.短篇小说:你不能。

Iframes do not allow interaction to and from the parent page, unless they are in the same domain. iframe 不允许与父页面进行交互,除非它们在同一个域中。

This is done by the browser for security reasons, so sadly you will have to figure a way around that, like maybe implementing a close button outside the iframe that hides it.出于安全原因,这是由浏览器完成的,所以遗憾的是,您必须想办法解决这个问题,比如可能在 iframe 之外实现一个关闭按钮来隐藏它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM