Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery Mobile pagebeforeload Event

jQuery Mobile pagebeforeload Event

jQuery Mobile Events jQuery Mobile Events

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:

**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:

  • url (string) - The absolute or relative address passed to $.mobile.loadPage() via callback
  • absUrl (string) - Contains an absolute reference to 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:** A callback function that calls preventDefault() for this event must call the resolve() or reject() method for this event, so that the changePage() request resumes. |

    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 jQuery Mobile Events