Struct moxie_dom::elements::text_semantics::ABuilder[][src]

#[must_use = "needs to be built"]pub struct ABuilder { /* fields omitted */ }

The HTML <a> element (or anchor element), along with its href attribute, creates a hyperlink to other web pages, files, locations within the same page, email addresses, or any other URL.

A type for initializing the element’s attributes before calling build.

Implementations

impl ABuilder[src]

pub fn download(self, to_set: impl ToString) -> Self[src]

Prompts the user to save the linked URL instead of navigating to it. Can be used with or without a value:

  • Without a value, the browser will suggest a filename/extension, generated from various sources:
    • The Content-Disposition HTTP header
    • The final segment in the URL path
    • The media type (from the (Content-Type header, the start of a data: URL, or Blob.type for a blob: URL)
  • Defining a value suggests it as the filename. / and \ characters are converted to underscores (_). Filesystems may forbid other characters in filenames, so browsers will adjust the suggested name if necessary.

Notes:

  • download only works for same-origin URLs, or the blob: and data: schemes.
  • If Content-Disposition has a different filename than download, the header takes priority. (If Content-Disposition: inline, Firefox prefers the header while Chrome prefers download.)

pub fn href(self, to_set: impl ToString) -> Self[src]

The URL that the hyperlink points to. Links are not restricted to HTTP-based URLs — they can use any URL scheme supported by browsers:

  • Sections of a page with fragment URLs
  • Pieces of media files with media fragments
  • Telephone numbers with tel: URLs
  • Email addresses with mailto: URLs
  • While web browsers may not support other URL schemes, web sites can with registerProtocolHandler()

pub fn hreflang(self, to_set: impl ToString) -> Self[src]

Hints at the human language of the linked URL. No built-in functionality. Allowed values are the same as the global lang attribute.

pub fn ping(self, to_set: impl ToString) -> Self[src]

A space-separated list of URLs. When the link is followed, the browser will send POST requests with the body PING to the URLs. Typically for tracking.

pub fn rel(self, to_set: impl ToString) -> Self[src]

The relationship of the linked URL as space-separated link types.

pub fn target(self, to_set: impl ToString) -> Self[src]

Where to display the linked URL, as the name for a browsing context (a tab, window, or <iframe>). The following keywords have special meanings for where to load the URL:

  • _self: the current browsing context. (Default)
  • _blank: usually a new tab, but users can configure browsers to open a new window instead.
  • _parent: the parent browsing context of the current one. If no parent, behaves as _self.
  • _top: the topmost browsing context (the “highest” context that’s an ancestor of the current one). If no ancestors, behaves as _self.

Note: When using target, add rel=“noreferrer noopener” to avoid exploitation of the window.opener API;

Note: Linking to another page with target=“_blank” will run the new page in the same process as your page. If the new page executes JavaScript, your page’s performance may suffer. This can also be avoided by using rel=“noreferrer noopener”.

pub fn type_(self, to_set: impl ToString) -> Self[src]

Hints at the linked URL’s format with a MIME type. No built-in functionality.

Trait Implementations

impl ElementBuilder for ABuilder[src]

impl<E> EventTarget<E> for ABuilder where
    E: GlobalEvent
[src]

impl GlobalEventHandler for ABuilder[src]

impl HtmlElementBuilder for ABuilder[src]

impl NodeBuilder for ABuilder[src]

type Output = A

The type of the DOM node

fn build(self) -> A[src]

Initialize the element with all of the attributes so far.

impl NodeWrapper for ABuilder[src]

impl<Child> Parent<Child> for ABuilder where
    Child: FlowContent
[src]

Auto Trait Implementations

impl !RefUnwindSafe for ABuilder

impl !Send for ABuilder

impl !Sync for ABuilder

impl Unpin for ABuilder

impl !UnwindSafe for ABuilder

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<N> Child for N where
    N: NodeWrapper
[src]

impl<T> Downcast for T where
    T: Any

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.