4
Как можно выгрузить событие iframe при его удалении?Как вызвать событие onunload при удалении iframe?
С помощью приведенного ниже кода, когда вызывается removeChild (iframe), событие onunload не запускается.
<!-- parent.html -->
<html>
<head>
<title>remove iframe</title>
<script type="text/javascript">
window.onload = function() {
var button = document.getElementsByTagName("BUTTON")[0];
button.onclick = function() {
document.body.removeChild(document.getElementsByTagName("IFRAME")[0]);
};
};
</script>
</head>
<body>
<iframe src="./son.html" />
<button>Remove iframe</botton>
</body>
</html>
<!-- son.html -->
<html>
<head>
<title>son html</title>
<script type="text/javascript">
window.onload = function() { alert("hello"); };
window.onunload = function() { alert("world!"); };
</script>
</head>
<body style="background-color:#aaccee;">
</body>
</html>
Как это можно вызвать?
он прекрасно работает в Firefox, но не в Chrome. Есть идеи? – ipinyol