Class BaseLocation


  • @JsType(isNative=true,
            name="Location",
            namespace="<global>")
    public final class BaseLocation
    extends Object
    Represents the location (URL) of the object it is linked to.
    Changes done on it are reflected on the object it relates to.
    Author:
    Andrea "Stock" Stocchero
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void assign​(String url)
      Causes the window to load and display the document at the URL specified.
      After the navigation occurs, the user can navigate back to the page that called Location.assign() by pressing the "back" button.
      String getHash()
      Is a string containing a '#' followed by the fragment identifier of the URL.
      String getHost()
      Is a string containing the host, that is the hostname, a ':', and the port of the URL.
      String getHostname()
      Is a string containing the domain of the URL.
      String getHref()
      Is a stringifier that returns a string containing the entire URL.
      If changed, the associated document navigates to the new page.It can be set from a different origin than the associated document.
      String getOrigin()
      Returns a string containing the canonical form of the origin of the specific location.
      String getParameter​(String name)
      Gets the URL parameter of the specified name.
      Note that if multiple parameters have been specified with the same name, the last one will be returned.
      Map<String,​List<String>> getParameterMap()
      Returns an unmodifiable map of the URL query parameters for the host page at the time this method was called.
      Any changes to the window's location will be reflected in the result of subsequent calls.
      String getPathname()
      Is a string containing an initial '/' followed by the path of the URL.
      String getPort()
      Is a string containing the port number of the URL.
      String getProtocol()
      Is a string containing the protocol scheme of the URL, including the final ':'.
      String getSearch()
      Is a string containing a '?' followed by the parameters or "querystring" of the URL.
      void reload()
      Reloads the current URL, like the Refresh button.
      void replace​(String url)
      Replaces the current resource with the one at the provided URL.
      The difference from the assign(String) method is that after using replace(String) the current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it.
    • Method Detail

      • getHash

        @JsProperty
        public final String getHash()
        Is a string containing a '#' followed by the fragment identifier of the URL.
        Returns:
        the fragment identifier of the URL
      • getHost

        @JsProperty
        public final String getHost()
        Is a string containing the host, that is the hostname, a ':', and the port of the URL.
        Returns:
        a string containing the host
      • getHostname

        @JsProperty
        public final String getHostname()
        Is a string containing the domain of the URL.
        Returns:
        a string containing the domain of the URL
      • getHref

        @JsProperty
        public final String getHref()
        Is a stringifier that returns a string containing the entire URL.
        If changed, the associated document navigates to the new page.It can be set from a different origin than the associated document.
        Returns:
        a stringifier that returns a string containing the entire URL
      • getOrigin

        @JsProperty
        public final String getOrigin()
        Returns a string containing the canonical form of the origin of the specific location.
        Returns:
        a string containing the canonical form of the origin of the specific location
      • getPathname

        @JsProperty
        public final String getPathname()
        Is a string containing an initial '/' followed by the path of the URL.
        Returns:
        a string containing the path of the URL.
      • getPort

        @JsProperty
        public final String getPort()
        Is a string containing the port number of the URL.
        Returns:
        a string containing the port number of the URL
      • getProtocol

        @JsProperty
        public final String getProtocol()
        Is a string containing the protocol scheme of the URL, including the final ':'.
        Returns:
        a string containing the protocol scheme of the URL
      • getSearch

        @JsProperty
        public final String getSearch()
        Is a string containing a '?' followed by the parameters or "querystring" of the URL.
        Returns:
        the query string of the URL
      • assign

        @JsMethod
        public final void assign​(String url)
        Causes the window to load and display the document at the URL specified.
        After the navigation occurs, the user can navigate back to the page that called Location.assign() by pressing the "back" button.
        Parameters:
        url - new resource to set to URL
      • reload

        @JsMethod
        public void reload()
        Reloads the current URL, like the Refresh button.
      • replace

        @JsMethod
        public void replace​(String url)
        Replaces the current resource with the one at the provided URL.
        The difference from the assign(String) method is that after using replace(String) the current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it.
        Parameters:
        url - new resource to set to URL
      • getParameter

        @JsOverlay
        public String getParameter​(String name)
        Gets the URL parameter of the specified name.
        Note that if multiple parameters have been specified with the same name, the last one will be returned.
        Parameters:
        name - the name of the URL parameter
        Returns:
        the value of the URL parameter, or null if missing
      • getParameterMap

        @JsOverlay
        public Map<String,​List<String>> getParameterMap()
        Returns an unmodifiable map of the URL query parameters for the host page at the time this method was called.
        Any changes to the window's location will be reflected in the result of subsequent calls.
        Returns:
        a map from URL query parameter names to a list of values