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

jQuery Mobile pageload event

jQuery Mobile pageload event

jQuery Mobile Events jQuery Mobile Events

Example

Pop up a message after an external page is successfully loaded and inserted into the DOM:

$(document).on("pageload",function(){

  alert("pageload event triggered!");

});

Try it »


Definition and Usage

Deprecated after version 1.4.0, use pagecontainerload as a replacement.

The pageload event is triggered after a page is successfully loaded and inserted into the DOM.

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 pageload (load succeeded) or pageloadfailed (load failed) after loading.


Syntax

$("document").on("pageload",function(event,data){...})

Parameters Description
function(event,data) Specifies the function to execute after the pageload 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
  • options (object) - Contains options sent to $.mobile.loadPage()
  • xhr (object) - Contains the XMLHttpRequest object (sent as the third parameter to the $.ajax() success callback)
  • textStatus (string or null) - Contains the request status ("success" or "null") (sent as the second parameter to the $.ajax() failure callback)
  • |

    More examples

    Related events demonstration.
    pageload and pageloadfailed event demo.

    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