Latest web development tutorials

jQuery Mobile pagebeforeload event

jQuery Mobile Events jQuery Mobile Events

Examples

Before loading request pop-up message:

$(document).on("pagebeforeload",function(){
alert("pagebeforeload 事件触发!");
});

try it"

Definition and Usage

pagebeforeload event is triggered before any load.

Related events:

  • pageLoad - successfully loaded and inserted into the DOM trigger page.
  • pageloadfailed - it triggered after the page failed to load.

Note: The external page is loaded into the DOM, the event will certainly trigger type 2. Before loading the pagebeforeload event, and after loading pageload (loaded successfully) or pageloadfailed (failed to load).


grammar

$ ( "Document"). On ( "pagebeforeload", function (event, data) {...})

parameter description
function (event, data) have to. Function is executed pagebeforeload specified event triggers.

This function includes the following two parameters:

Event objects - including any jQuery event properties (event.target, event.type etc.). For more information, please refer jQuery Event Manual

Data Objects - contains the following types:

  • url (string) - reached $ .mobile.loadPage through the callback () absolute or relative address
  • absUrl (string) - URL contains an absolute reference
  • dataUrl (string) - URL location that contains the browser
  • deferred (object) - contains the resolve () or reject ()
  • options (object) - contains options to send $ .mobile.loadPage ()
Note: Calling preventDefault for this event () callback function must resolve to call for this event () or reject () method, so changePage () request to recovery.


Examples

More examples

Related events Demo
This example demonstrates the pageload and pageloadfailed.

Event objects
Use event.type property to return the type of trigger event.

Data Objects
Use data.url return external URL of the page.


jQuery Mobile Events jQuery Mobile Events