How to call unload event of iframe?

Member

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

How to call unload event of iframe?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by darrion.kuhn , 8 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.

Related Threads:

How to call a function on 'load' event in d3.js?
How to add an event listener to an iframe?
How to attach click event on iframe?
How to capture click event with jquery for iframe?
How to bind event to element in iframe?
How to access event "onplay()" for iframe?