0

Hope people can help - been using 'Stack Over Flow' for reference for many years now, but this is the first time I'm stuck on some coding. Below is the iFrame, what I would like to happen is when the submit button on the form has been clicked is for it to disappear, but instead the iFrame is still there and within the iFrame it goes to 'How can we help you today?'

Also, when the iFrame disappears a line of text should appear.

<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>

Many thanks for the help!

2 Answers2

0

You can find the possible answer in this post- https://stackoverflow.com/a/3690896/8438534

As mentioned in that answer, if the click is in the iframe area, the iframe context handles the click event, it does not bubble up to the iframe parent. So the div will never register the click event at all if it happened in the iframe area.

Sandip Ghosh
  • 719
  • 7
  • 13
0

try this

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();
            }
    }
ali zarei
  • 1,212
  • 11
  • 17