希望人们可以提供帮助 - 多年来一直使用'Stack Over Flow'作为参考,但这是我第一次坚持编码。下面是iFrame,我想要发生的是当单击表单上的提交按钮时它会消失,但iFrame仍然在那里,在iFrame中它会转到'我们今天如何帮助你? “
此外,当iFrame消失时,应出现一行文字。
<script type="text/javascript">
function removeIFrame() {
var frame = document.getElementById("myIframe");
frame.parentNode.removeChild(frame);
}
</script>
<div style="overflow: hidden;position: relative;height: 970px; width:150%;" onclick="removeIFrame();">
<iframe id="myIframe" src="https://sheersense.freshdesk.com/support/tickets/new" scrolling="no" width="100%" height="1125px" frameborder="0" style="position: absolute; top:-150px"></iframe>
<div id="text_display" style="">Thank you for your ticket, a member of the Sheersense team will be in touch with you shortly.</div>
</div>
非常感谢您的帮助!
答案 0 :(得分:0)
你可以在这篇文章中找到可能的答案 - https://stackoverflow.com/a/3690896/8438534
如该答案所述,如果点击位于iframe区域,iframe上下文会处理点击事件,它不会冒泡到iframe父级。因此,如果它发生在iframe区域,div将永远不会注册click事件。
答案 1 :(得分:0)
试试这个
function removeIFrame() {
var frame = document.getElementById("myIframe");
frame.remove();
}
window.onload = function() {
var frame = window.myIframe;
var innerDocument = (frame.contentWindow || frame.contentDocument);
if (innerDocument.document) innerDocument = innerDocument.document;
innerDocument.onclick =function() {
removeIFrame();
}
}