티스토리 뷰

Javascript

최상위 window의 parent

딩신 2021. 1. 19. 01:21

developer.mozilla.org/en-US/docs/Web/API/Window/parent

 

Window.parent - Web APIs | MDN

The Window.parent property is a reference to the parent of the current window or subframe. If a window does not have a parent, its parent property is a reference to itself. When a window is loaded in an , , or , its parent is the window with the element em

developer.mozilla.org

 

If a window does not have a parent, its parent property is a reference to itself.

에 의해 최상위 window의 parent는 자신이다. 그 parent도..

 

webview에서 페이지를 띄우는데, 페이지에서 iframe을 사용할 때도 있어서 window.postmessage를 날려야할 때도 있고, iframe 내에서도 window.parent.postMessage를 날려야 할 때가 있는데, 일괄적으로 window.parent.postMessage를 넣어 해결(어차피 최상위는 parent가 본인이므로)

 

하지만 iframe에서 다른식으로 통신해야 할 수도 있기 때문에 항상 조심해야할듯..

댓글