4
iframe의 언로드 이벤트를 제거 할 때 어떻게 트리거 될 수 있습니까?iframe을 제거 할 때 onunload 이벤트를 트리거하는 방법은 무엇입니까?
아래 코드를 사용하면 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>
어떻게 트리거 할 수 있습니까?
은 크롬에서 파이어 폭스에서 잘 작동하지만,하지. 어떤 아이디어? – ipinyol