how to sync window.top.location and window.location?
top. Returns a reference to the topmost window in the window hierarchy.
The Complete Full-Stack JavaScript Course! Window. location is the location property of a window and it is a reference to a Location object; it represents the current URL of the document being displayed in that window. Since window object is at the top of the scope chain, so properties of the window.
The window. location is read/write on all compliant browsers. The document. location is read-only in Internet Explorer but read/write in Firefox, SeaMonkey that are Gecko-based browsers.
The Window top() property is used to return the topmost browser window of a current window. It is a read-only property and it returns a reference to the topmost window in the window hierarchy. Syntax: window.top. Return Value: It returns the reference of the topmost window in the window hierarchy.
This is how you set the parent of the frame (top
) to the location of the frame document...
top.location = self.location;
Of course, this code must be executed within the iframe, and is succeptible to the Same-Origin Policy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With