jQuery Mobile pagebeforeload Event
Example
Display a message before the load request:
Definition and Usage
The pagebeforeload event is triggered before any loading occurs.
Related Events:
pageload - Triggered when the page is successfully loaded and inserted into the DOM.
pageloadfailed - Triggered after a page load fails.
Note: When an external page is loaded into the DOM, two types of events are definitely triggered. The pagebeforeload event before loading, and either the pageload (successful load) or pageloadfailed (failed load) event afterward.
Syntax
| Parameter | Description |
|---|---|
| function(event, data) | Required. Specifies the function to run when the pagebeforeload event is triggered. The function contains the following two parameters: Event Object - Includes any jQuery event properties (event.target, event.type, etc.). For more information, see the jQuery Event Reference. Data Object - Contains the following types: url (string) - The absolute or relative address passed to $.mobile.loadPage() via the callback. absUrl (string) - Contains the absolute reference of the URL. dataUrl (string) - Contains the browser's URL location. deferred (object) - Contains resolve() or reject(). options (object) - Contains options sent to $.mobile.loadPage(). Note: The callback function calling preventDefault() for this event must call either resolve() or reject() methods to resume the changePage() request. |