Event Pagebeforeload
# jQuery Mobile pagebeforeload Event
[ jQuery Mobile Events](#)
## Example
Show an alert before the load request:
$(document).on("pagebeforeload",function(){
alert("pagebeforeload event triggered!");
});
[Try it yourself Β»](#)
* * *
## Definition and Usage
The pagebeforeload event is triggered before any load occurs.
**Related Events:**
- Triggered after a page is successfully loaded and inserted into the DOM.
- Triggered after a page fails to load.
**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 (load success) or pageloadfailed (load failure) event after loading.
* * *
## Syntax
$("document").on("pagebeforeload",function(event,data){...})
| Parameter | Description |
| --- | --- |
| function(event,data) | Required. Specifies the function to run when the pagebeforeload event is triggered. This function has two parameters: **Event object** - Contains any jQuery event properties (event.target, event.type, etc.). For more information, see the (#). **Data object** - Contains the following types: * **url** (string) - The absolute or relative URL 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 the options sent to $.mobile.loadPage(). **Note:** Callbacks that call preventDefault() for this event must call either resolve() or reject() for this event to resume the changePage() request. |
* * *

## More Examples
(#)
This example demonstrates pageload and pageloadfailed.
(#)
Use the event.type property to return the type of event triggered.
(#)
Use data.url to return the URL of the external page.
* * jQuery Mobile Events](#)
YouTip