Check if parent window is iframe or not

后端 未结 3 605
醉梦人生
醉梦人生 2020-11-29 21:48

How can I tell from a page within an iframe, if the parent itself is also within an iframe?

Explanation:

My home page home.ht

3条回答
  •  一整个雨季
    2020-11-29 22:04

    This is true if a window is not a frame/iframe:

    if(self==top)
    

    If you like to see if the parent window of the given window is a frame, use:

    if(parent==top)
    

    It's a simple comparision of top (the most top window of the window hierarchy) and another window object (self or parent).

提交回复
热议问题