Location Class

Location class

Location objects provide a representation of the address of the active document of their Document’s browsing context, and allow the current entry of the browsing context’s session history to be changed, by adding or replacing entries in the history object.

public sealed class Location : DOMObject

Properties

NameDescription
Hash { get; set; }Returns the Location object’s URL’s fragment (includes leading “#” if non-empty). Can be set, to navigate to the same URL with a changed fragment(ignores leading “#”).
Host { get; set; }Returns the Location object’s URL’s host and port (if different from the default port for the scheme). Can be set, to navigate to the same URL with a changed host and port.
Hostname { get; set; }Returns the Location object’s URL’s host. Can be set, to navigate to the same URL with a changed host.
Href { get; set; }Returns the Location object’s URL. Can be set, to navigate to the given URL.
Origin { get; }Returns the Location object’s URL’s origin.
Pathname { get; set; }Returns the Location object’s URL’s path. Can be set, to navigate to the same URL with a changed path.
Port { get; set; }Returns the Location object’s URL’s port. Can be set, to navigate to the same URL with a changed port.
Protocol { get; set; }Returns the Location object’s URL’s scheme. Can be set, to navigate to the same URL with a changed scheme.
Search { get; set; }Returns the Location object’s URL’s query (includes leading “?” if non-empty). Can be set, to navigate to the same URL with a changed query(ignores leading “?”).

Methods

NameDescription
Assign(string)Navigates to the given page.
virtual GetPlatformType()This method is used to retrieve ECMAScript object Type.
Reload()Reloads the current page.
Replace(string)Removes the current page from the session history and navigates to the given page.
override ToString()Returns the Location object’s URL.

See Also