Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.name is not persistent in Google Chrome

I'm seeing a strange behavior in Google Chrome, using the window.name property.

For example:

  1. open a tab and go to http://google.com .

  2. Open up console, and type window.name="hello".

  3. Now in the same tab, go to http://chase.com.

  4. In the console, type window.name.

I expect to see "hello" returned, but instead I see "".

Is this a known issue for Google Chrome? It works for me in FireFox.

Anyone have any insight to this behavior?

Thanks!


Update:

If, instead of typing in a new URL, I type window.location="http://chase.com", then the window.name persists!

like image 780
d-_-b Avatar asked Nov 25 '22 04:11

d-_-b


1 Answers

window is a global object for each document, not for the browser window. In a page with iframes you will have one window for each iframe for example. Each time a document is loaded, a new global object is created and populated for the context. When the document is unloaded, the global object along with all its data is destroyed.

like image 161
Tihauan Avatar answered Jan 02 '23 16:01

Tihauan