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

jQuery Mobile pagecontainerbeforeload event

jQuery Mobile pagecontainerbeforeload event

jQuery Mobile Events jQuery Mobile Events

Example

Pop up a message before the request is loaded:

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

  alert("pagecontainerbeforeload event triggered!");

});

Try it »


Definition and Usage

The pagecontainerbeforeload event is triggered before a request is loaded.

Related events:

**Note:** This event is for external pages - after a page is loaded and inserted into the DOM, 2 events are triggered. The first is pagecontainerbeforeload, and the second may be pagecontainerload or pagecontainerloadfailed.


Syntax



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

Parameters Description
function(event,data) Required. Specifies the function to execute after the event is triggered.

This function has two optional parameters:

event object - Contains jQuery event properties (such as event.target, event.type, etc.), see jQuery event reference manual for more information.

data object - Contains the following:

  • url (string) - The absolute or relative URL of the page (sent to $.mobile.loadPage())
  • absUrl (string) - The absolute path of the URL
  • dataUrl (string) - The corresponding URL in the browser
  • deferred (object) - Contains resolve() or reject()
  • options (object) - Optional options sent to $.mobile.loadPage()
  • **Note:** In the event object you can manually handle the request by calling event.preventDefault(). The deferred object in the data object contains the resolve() or reject() methods. |

    More examples

    Related events demonstration
    pagecontainerload and pagecontainerloadfailed event examples.

    event object
    Use the event.type property to return the type of event triggered.

    data object
    Use data.url to return the URL of the external page.