What's the difference between self and window?

后端 未结 4 568
夕颜
夕颜 2020-11-29 09:20

I have a JavaScript that deals with with detection whether the page is in frames or not. I used top.frames[] etc. and everything works fine.

In this script I notice

4条回答
  •  情话喂你
    2020-11-29 09:39

    From Javascript: The Definitive Guide:

    The Window object defines a number of properties and methods that allow you to manipulate the web browser window. It also defines properties that refer to other important objects, such as the document property for the Document object. Finally, the Window object has two self-referential properties, window and self. You can use either global variable to refer directly to the Window object.

    In short, both window and self are references to the Window object, which is the global object of client-side javascript.

提交回复
热议问题