X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

jQuery pageload Event

jQuery Mobile Events jQuery Mobile Events

Example

Alert some text when the external page has been successfully loaded and inserted into the DOM:

$(document).on("pageload",function(){
  alert("pageload event fired!");
});

Try it yourself »

Definition and Usage

The pageload event was deprecated in jQuery version 1.4.0. Use the pagecontainerload event instead.

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

Related events:

Note: These events are used for external pages - Whenever an external page is loaded into the DOM, 2 events are fired. The first is pagebeforeload. The 2nd event will either be pageload or pageloadfailed.


Syntax

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

Parameter Description
function(event,data) Required. Specifies the function to run when the pageload event occurs.

The function has two optional parameters:

The event object - which can contain any jQuery event properties (e.g. event.target, event.type, etc.) See jQuery Events Reference for more information

The data object - contains the following:

  • url (string) - contains the absolute or relative URL of the page (that was sent to $.mobile.loadPage())
  • absUrl (string) - contains the absolute reference of the URL
  • dataUrl (string) - contains the URL of the browser's location
  • options (object) - contains the options that were sent to $.mobile.loadPage()
  • xhr (object) - contains the XMLHttpRequest object (Sent as the 3rd argument to $.ajax() success callback)
  • textStatus (string or null) - contains the status of the request ("success" or "null") (Sent as the 2nd argument to $.ajax() error callback)


Examples

Try it Yourself - Examples

A demonstration of related events
A demonstration of pageload and pageloadfailed.

The event object
Using the event.type property to return the triggered event type.

The data object
Using data.url to return the URL of the external page.


jQuery Mobile Events jQuery Mobile Events


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook