Difference between browser tab and window

后端 未结 2 1090
青春惊慌失措
青春惊慌失措 2021-01-05 04:49

In web browsers each window has its own JavaScript environment, with its own global object. But it looks like that opening a new tab in the same window also creates a differ

相关标签:
2条回答
  • 2021-01-05 05:15

    The only difference is how the window is presented to the user. Each Tab/Window has a totally separate DOM (Document Object Model) and JavaScript environment.

    Most browsers will share Cookies and therefore Sessions between tabs and new windows. Some have an 'incognito' mode which prevents sharing of sessions between incognito and normal mode windows.

    0 讨论(0)
  • 2021-01-05 05:32

    Yes, if you open the same page in new window or tab, the global objects or variables will be created again and if you would have made some changes or modifications in tab A or window B and which had somehow changed the value of global objects or variables then it won't get reflected in tab C or window D unless you save it explicitly to the server and fetch it again from there. You cannot retain the value of global objects, they will be created again. Note that the session variables or objects will be same throughout.

    Difference between tab and window

    A tab is more or less same as a window. A window can contain several tabs and all session data and cookies are shared across all tabs and open window. It's better to open a lot of tabs than opening several windows because too many window becomes too cluttered to handle.

    An incognito(private mode browsing) window doesn't share any information with regular window or any of the tabs in regular window, but all the tabs in an incognito window share the similar session data or cookies. A new instance of an incognito window will also behave as a new tab in incognito window and will share session data or cookies of that of incognito window.

    0 讨论(0)
提交回复
热议问题