pub enum Target {
Self_,
Blank,
Parent,
Top,
}Expand description
The target attribute values for hyperlinks and forms.
§Purpose
Specifies where to display the linked URL or form response, controlling whether content opens in a new window, the same frame, or a specific context.
§Usage Context
- Used with:
<a>,<area>,<form>,<base>elements - Security: Use with
rel="noopener"when opening in new window
§Valid Values
Self_: Open in the same browsing context (default)Blank: Open in a new window or tabParent: Open in the parent browsing contextTop: Open in the top-most browsing context
§Example
use ironhtml_attributes::{AttributeValue, Target};
let target = Target::Blank;
assert_eq!(target.to_attr_value(), "_blank");<a href="https://example.com" target="_blank">Open in new tab</a>
<a href="/page" target="_self">Open in same tab</a>
<form action="/submit" target="_parent" method="post">...</form>§WHATWG Specification
Variants§
Self_
Open in the same browsing context (frame/tab). This is the default behavior when target is not specified.
Blank
Open in a new, unnamed browsing context (typically a new tab or window).
For security, use with rel="noopener noreferrer".
Parent
Open in the parent browsing context. If no parent exists, behaves
like _self.
Top
Open in the top-level browsing context (the highest-level ancestor).
If no ancestors exist, behaves like _self.
Trait Implementations§
Source§impl AttributeValue for Target
impl AttributeValue for Target
Source§fn to_attr_value(&self) -> Cow<'static, str>
fn to_attr_value(&self) -> Cow<'static, str>
Convert to the attribute value string.
impl Copy for Target
impl Eq for Target
impl StructuralPartialEq for Target
Auto Trait Implementations§
impl Freeze for Target
impl RefUnwindSafe for Target
impl Send for Target
impl Sync for Target
impl Unpin for Target
impl UnwindSafe for Target
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more