jQuery Mobile pagebeforeload Event
Example
Information pops up before the load request:
$(document).on("pagebeforeload",function(){
alert("pagebeforeload event triggered!");
});
Try it »
Definition and Usage
pagebeforeload is an event triggered before any loading.
Related events:
- pageload - Triggered when a page is successfully loaded and inserted into the DOM.
- pageloadfailed - 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 the pageload (load successful) or pageloadfailed (load failed) event after loading.
Syntax
$("document").on("pagebeforeload",function(event,data){...})
| Parameters | Description |
|---|---|
| function(event,data) | Required. Specifies the function to execute when the pagebeforeload event is triggered.
This function contains the following two parameters: Event Object - Includes any jQuery event properties (event.target, event.type, etc.). For more information, refer to the jQuery event reference manual Data object - Contains the following types: |
More examples
Related events demonstration
This example demonstrates pageload and pageloadfailed.
Event Object
Use the event.type property to return the type of event that was triggered.
Data object
Use data.url to return the URL of the external page.
jQuery Mobile Events