Module org.htmlunit

Class HyperlinkElementSupport

java.lang.Object
org.htmlunit.html.HyperlinkElementSupport

public final class HyperlinkElementSupport extends Object
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
A helper class to be used by elements which support HyperlinkElement - currently HtmlAnchor (a) and HtmlArea (area), the two elements the HTML spec defines as "hyperlink elements".
Author:
Ronald Brill
  • Method Details

    • doClickStateUpdate

      public static void doClickStateUpdate(HyperlinkElement element, boolean shiftKey, boolean ctrlKey, String hrefSuffix) throws IOException
      Support method that is called from HtmlAnchor.doClickStateUpdate(boolean, boolean, String) and HtmlArea.doClickStateUpdate(boolean, boolean): resolves the target URL, sends the hyperlink-auditing ("ping") request if applicable, builds the navigation WebRequest (including Sec-Fetch-* setup), and hands it off for download/navigation.
      Parameters:
      element - the hyperlink element being clicked
      shiftKey - true if SHIFT is pressed
      ctrlKey - true if CTRL is pressed
      hrefSuffix - the suffix to add to the element's href attribute (for instance coordinates from an image map)
      Throws:
      IOException - if an IO error occurs
    • relContainsNoreferrer

      public static boolean relContainsNoreferrer(HyperlinkElement element)
      Returns true if the element's rel attribute contains noreferrer.
      Parameters:
      element - the hyperlink element
      Returns:
      true if the element's rel attribute contains noreferrer
    • getTargetUrl

      public static URL getTargetUrl(String href, HtmlPage page) throws MalformedURLException
      Returns the calculated target url.
      Parameters:
      href - the href
      page - the HtmlPage
      Returns:
      the calculated target url.
      Throws:
      MalformedURLException - if an IO error occurs