[][src]Struct stdweb::web::event::PopStateEvent

pub struct PopStateEvent(_);

A PopStateEvent is dispatched to the window every time the active history entry changes between two history entries for the same document. If the history entry being activated was created by a call to history.push_state() or was affected by a call to history.replace_state(), the PopStateEvent's state property contains a copy of the history entry's state object.

Note that just calling history.push_state() or history.replace_state() won't trigger a PopStateEvent. The PopStateEvent is only triggered by doing a browser action such as a clicking on the back button (or calling history.back()). And the event is only triggered when the user navigates between two history entries for the same document.

Browsers tend to handle the PopStateEvent differently on page load. Chrome and Safari always emit a PopStateEvent on page load, but Firefox doesn't.

(Javascript docs)

Methods

impl PopStateEvent[src]

pub fn state(&self) -> Value[src]

The state object associated to the new history entry, if that entry was created with push_state or affected by replace_state.

Example usage:

This example is not tested
let state: Option<MyStruct> = event.state().try_into().ok();

Trait Implementations

impl JsSerialize for PopStateEvent[src]

impl TryFrom<PopStateEvent> for Reference[src]

type Error = Void

The type returned in the event of a conversion error.

impl TryFrom<Reference> for PopStateEvent[src]

type Error = ConversionError

The type returned in the event of a conversion error.

impl<'_r> TryFrom<&'_r Reference> for PopStateEvent[src]

type Error = ConversionError

The type returned in the event of a conversion error.

impl TryFrom<Value> for PopStateEvent[src]

type Error = ConversionError

The type returned in the event of a conversion error.

impl<'_r> TryFrom<&'_r Value> for PopStateEvent[src]

type Error = ConversionError

The type returned in the event of a conversion error.

impl InstanceOf for PopStateEvent[src]

impl ReferenceType for PopStateEvent[src]

impl IEvent for PopStateEvent[src]

impl ConcreteEvent for PopStateEvent[src]

impl AsRef<Reference> for PopStateEvent[src]

impl From<PopStateEvent> for Reference[src]

impl Clone for PopStateEvent[src]

impl Eq for PopStateEvent[src]

impl PartialEq<PopStateEvent> for PopStateEvent[src]

impl Debug for PopStateEvent[src]

Auto Trait Implementations

Blanket Implementations

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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