How to call unload event of iframe?

Member

by adan , in category: Third Party Scripts , 4 months ago

How to call unload event of iframe?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by darrion.kuhn , 4 months ago

@adan 

To call the unload event of an iframe, you can use the following JavaScript code:

1
2
3
4
var iframe = document.getElementById('yourIframeId');
iframe.contentWindow.onunload = function() {
  // Your code to handle the unload event
};


Replace 'yourIframeId' with the id of your iframe element. This code will attach a handler to the unload event of the iframe's content window, allowing you to perform actions when the iframe is unloaded.