Class HTMLAnchorElement

All Implemented Interfaces:
Serializable, Cloneable, org.htmlunit.corejs.javascript.ConstProperties, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable

public class HTMLAnchorElement extends HTMLElement
The JavaScript object that represents an anchor.
See Also:
  • Field Details

    • REFERRER_POLICIES

      private static final List<String> REFERRER_POLICIES
  • Constructor Details

    • HTMLAnchorElement

      public HTMLAnchorElement()
      The constructor.
  • Method Details

    • jsConstructor

      public void jsConstructor()
      JavaScript constructor.
      Overrides:
      jsConstructor in class HTMLElement
    • setHref

      public void setHref(String href)
      Sets the href property.
      Parameters:
      href - the href property value
    • getHref

      public String getHref()
      Returns the value of this link's href property.
      Returns:
      the value of this link's href property
    • focus

      public void focus()
      Sets the focus to this element.
      Overrides:
      focus in class HTMLElement
    • setName

      public void setName(String name)
      Sets the name property.
      Overrides:
      setName in class HTMLElement
      Parameters:
      name - name attribute value
    • getName

      public String getName()
      Returns the value of the name property of this link.
      Overrides:
      getName in class HTMLElement
      Returns:
      the name property
    • setTarget

      public void setTarget(String target)
      Sets the target property of this link.
      Parameters:
      target - target attribute value
    • getTarget

      public String getTarget()
      Returns the value of the target property of this link.
      Returns:
      the href property
    • getUrl

      private URL getUrl() throws MalformedURLException
      Returns this link's current URL.
      Returns:
      this link's current URL
      Throws:
      MalformedURLException - if an error occurs
    • setUrl

      private void setUrl(URL url)
      Sets the href attribute of this link to the specified URL.
      Parameters:
      url - the new value of the href attribute
    • setRel

      public void setRel(String rel)
      Sets the rel property.
      Parameters:
      rel - rel attribute value
    • getRel

      public String getRel()
      Returns the value of the rel property.
      Returns:
      the rel property
    • getRev

      public String getRev()
      Returns the value of the rev property.
      Returns:
      the rev property
    • setRev

      public void setRev(String rel)
      Sets the rev property.
      Parameters:
      rel - rev attribute value
    • getReferrerPolicy

      public String getReferrerPolicy()
      Returns the value of the rev property.
      Returns:
      the referrerPolicy property
    • setReferrerPolicy

      public void setReferrerPolicy(String referrerPolicy)
      Sets the rev property.
      Parameters:
      referrerPolicy - referrerPolicy attribute value
    • getSearch

      public String getSearch()
      Returns the search portion of the link's URL (the portion starting with '?' and up to but not including any '#').
      Returns:
      the search portion of the link's URL
      See Also:
    • setSearch

      public void setSearch(String search) throws Exception
      Sets the search portion of the link's URL (the portion starting with '?' and up to but not including any '#')..
      Parameters:
      search - the new search portion of the link's URL
      Throws:
      Exception - if an error occurs
      See Also:
    • getHash

      public String getHash()
      Returns the hash portion of the link's URL (the portion following the '#', including the '#').
      Returns:
      the hash portion of the link's URL
      See Also:
    • setHash

      public void setHash(String hash) throws Exception
      Sets the hash portion of the link's URL (the portion following the '#').
      Parameters:
      hash - the new hash portion of the link's URL
      Throws:
      Exception - if an error occurs
      See Also:
    • getHost

      public String getHost()
      Returns the host portion of the link's URL (the '[hostname]:[port]' portion).
      Returns:
      the host portion of the link's URL
      See Also:
    • setHost

      public void setHost(String host) throws Exception
      Sets the host portion of the link's URL (the '[hostname]:[port]' portion).
      Parameters:
      host - the new host portion of the link's URL
      Throws:
      Exception - if an error occurs
      See Also:
    • getHostname

      public String getHostname()
      Returns the hostname portion of the link's URL.
      Returns:
      the hostname portion of the link's URL
      See Also:
    • setHostname

      public void setHostname(String hostname) throws Exception
      Sets the hostname portion of the link's URL.
      Parameters:
      hostname - the new hostname portion of the link's URL
      Throws:
      Exception - if an error occurs
      See Also:
    • getPathname

      public String getPathname()
      Returns the pathname portion of the link's URL.
      Returns:
      the pathname portion of the link's URL
      See Also:
    • setPathname

      public void setPathname(String pathname) throws Exception
      Sets the pathname portion of the link's URL.
      Parameters:
      pathname - the new pathname portion of the link's URL
      Throws:
      Exception - if an error occurs
      See Also:
    • getPort

      public String getPort()
      Returns the port portion of the link's URL.
      Returns:
      the port portion of the link's URL
      See Also:
    • setPort

      public void setPort(String port) throws Exception
      Sets the port portion of the link's URL.
      Parameters:
      port - the new port portion of the link's URL
      Throws:
      Exception - if an error occurs
      See Also:
    • getProtocol

      public String getProtocol()
      Returns the protocol portion of the link's URL, including the trailing ':'.
      Returns:
      the protocol portion of the link's URL, including the trailing ':'
      See Also:
    • setProtocol

      public void setProtocol(String protocol) throws Exception
      Sets the protocol portion of the link's URL.
      Parameters:
      protocol - the new protocol portion of the link's URL
      Throws:
      Exception - if an error occurs
      See Also:
    • getDefaultValue

      public Object getDefaultValue(Class<?> hint)
      Calls for instance for implicit conversion to string.
      Specified by:
      getDefaultValue in interface org.htmlunit.corejs.javascript.Scriptable
      Overrides:
      getDefaultValue in class HtmlUnitScriptable
      Parameters:
      hint - the type hint
      Returns:
      the default value
      See Also:
    • getDefaultValue

      static String getDefaultValue(HtmlElement element)
    • getText

      public String getText()
      Returns the text attribute.
      Returns:
      the text attribute
    • setText

      public void setText(String text)
      Sets the text attribute.
      Parameters:
      text - the text attribute
    • getCharset

      public String getCharset()
      Returns the charset attribute.
      Returns:
      the charset attribute
    • setCharset

      public void setCharset(String charset)
      Sets the charset attribute.
      Parameters:
      charset - the charset attribute
    • getCoords

      public String getCoords()
      Returns the coords attribute.
      Returns:
      the coords attribute
    • setCoords

      public void setCoords(String coords)
      Sets the coords attribute.
      Parameters:
      coords - coords attribute
    • getHreflang

      public String getHreflang()
      Returns the hreflang attribute.
      Returns:
      the hreflang attribute
    • setHreflang

      public void setHreflang(String hreflang)
      Sets the hreflang attribute.
      Parameters:
      hreflang - hreflang attribute
    • getOrigin

      public String getOrigin()
      Returns the origin attribute.
      Returns:
      the origin attribute
    • getUsername

      public String getUsername()
      Returns the username attribute.
      Returns:
      the username attribute
    • setUsername

      public void setUsername(String username)
      Sets the username attribute.
      Parameters:
      username - username attribute
    • getPassword

      public String getPassword()
      Returns the password attribute.
      Returns:
      the password attribute
    • setPassword

      public void setPassword(String password)
      Sets the password attribute.
      Parameters:
      password - password attribute
    • getDownload

      public String getDownload()
      Returns the download attribute.
      Returns:
      the download attribute
    • setDownload

      public void setDownload(String download)
      Sets the download attribute.
      Parameters:
      download - download attribute
    • getPing

      public String getPing()
      Returns the ping attribute.
      Returns:
      the ping attribute
    • setPing

      public void setPing(String ping)
      Sets the ping attribute.
      Parameters:
      ping - ping attribute
    • getShape

      public String getShape()
      Returns the shape attribute.
      Returns:
      the shape attribute
    • setShape

      public void setShape(String shape)
      Sets the shape attribute.
      Parameters:
      shape - shape attribute
    • getType

      public String getType()
      Returns the type attribute.
      Returns:
      the type attribute
    • setType

      public void setType(String type)
      Sets the type attribute.
      Parameters:
      type - type attribute
    • getRelList

      public DOMTokenList getRelList()
      Returns the relList attribute.
      Returns:
      the relList attribute
    • setRelList

      public void setRelList(Object rel)
      Sets the relList property.
      Parameters:
      rel - attribute value