iframe 내부에서 unbeforeunload 이벤트를 설정하면 iframe의 링크를 클릭 할 때 트리거되지 않습니다. 그것은 IE와 Firefox에서 작동하지만 Opera는 일반적인 AFAIK에서 onbeforeunload를 지원하지 않습니다.iframe의 onbeforeunload 이벤트가 Google 크롬에서 실행되지 않습니다. Firefox에서 작동합니다.
내가 궁금한 점이 있습니까? 이 행동이 가능하지 않아야합니까? 아니면 Google 크롬/웹킷의 버그입니까? 해결 방법은 무엇입니까?
코드 예제 :
인 test.html :
<html>
<body>
<p>Main page content</p>
<script type="text/javascript">
window.onbeforeunload = function() {alert('unloadevent in main window');};
</script>
<iframe id="tpa" src="..test2.html"></iframe>
</body>
</html>
test2.html :
<html>
<body>
<script type="text/javascript">
self.onbeforeunload = function() {alert('unloadevent in frame window');};
</script>
<a href="http://www.google.com/">Link to for instance google</a>
</body>
</html>
일부 설명해주세요. – vonbrand