javascript - Close iFrame On Button Click Within Itself -


i load iframe of page of website dynamically. close iframe clicking on "x" button within iframe. have created jquery function in main javascript file, , have added javascript page frame (within own domain).

in main js file:

var closeiframe = function() {     $('#iframecontact').remove();     $("#overlay").toggleclass("overflowhidden overflow"); }; 

on iframe page (at bottom of page's html):

<script> $("#menuoverlayback").click(function(){     parent.closeiframe(); } 

i have tried putting "onclick" html element on button no avail:

<i class="menuoverlayback material-icons" id="menuoverlayback" onclick="parent.closeiframe()">arrow_back</i> 

try using jquery modify visibility of iframe when "x" clicked..

$("#close").click(function() {   $("#myiframe").css({"display": 'none'}); }); 

Comments