This topic describes the JavaScript APIs of WVUIDialog. You can refer to this topic when you create HTML5 apps or MiniApps. The JavaScript APIs of WVUIDialog provide various capabilities, such as prompt messages, confirmation messages, warning messages, and permission guidance messages.
WVUIDialog.alert
Displays a warning message.
Effect on iOS devices | Effect on Android devices |
|
|
Input parameters
[
string]message: the warning message that you want to display.[
string]okbutton: the OK button in the warning message.[
string]identifier: the identifier of the warning message.
Event listening
The WV.Event.Alert event indicates that you respond to the warning message.
Event parameters:
[
string]identifier: the identifier of the warning message.
Callback parameters
No callback parameters exist. If the warning message is displayed, the success callback is invoked. Otherwise, the failure callback is invoked.
var params = {
// The warning message that you want to display.
message: 'Hello World!',
// The OK button in the warning message.
okbutton: 'OK',
};
window.WindVane.call('WVUIDialog', 'alert', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
WVUIDialog.confirm
Displays a confirmation message.
Effect on iOS devices | Effect on Android devices |
|
|
Input parameters
[
string]message: the confirmation message that you want to display.[
string]okbutton: the OK button in the confirmation message.[
string]cancelbutton: the Cancel button in the confirmation message.[
int]_index: the index of the confirmation message. The index uniquely identifies a confirmation message.
Callback parameters
No callback parameters exist. If the confirmation message is displayed, the success callback is invoked. Otherwise, the failure callback is invoked.
Event listening
The wv.dialog event indicates that you respond to the confirmation message.
Event parameters:
[
string]type: the text of the button that you tap. The value can beokbuttonorcanclebuttonin the input parameters.[
int]_index: the index of the confirmation message. The value is the same as the value of the input parameter_index.
document.addEventListener('wv.dialog', function(e) {
alert(JSON.stringify(e.param));
}, false);
var params = {
// The confirmation message that you want to display.
message: 'Are you really really sure?',
// The OK button in the confirmation message.
okbutton: 'OK',
// The Cancel button in the confirmation message.
canclebutton: 'Cancel',
// The index of the confirmation message.
_index: 10086
};
window.WindVane.call('WVUIDialog', 'confirm', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
WVUIDialog.enableAlertBeforeUnload
This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.
Enables the inquiry dialog for closing the MiniApp page. If the feature has been enabled, when you try to close the MiniApp page by clicking the Back button, the "Confirm to leave" dialog appears.
Input parameters
[
string]message: optional. The message displayed in the dialog. If you do not specify the message, the default message is "Confirm to leave?"
Callback parameters
Parameters for a success callback:
No callback parameters exist.
Parameters for a failure callback:
[
string]msg: the error message.
var params = {
// The content in the dialog.
message: 'Confirm to leave?',
};
window.WindVane.call('WVUI', 'enableAlertBeforeUnload', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});WVUIDialog.disableAlertBeforeUnload
This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.
Disables the inquiry dialog for closing the MiniApp page.
Input parameters
No input parameters exist.
Callback parameters
Parameters for a success callback:
No callback parameters exist.
Parameters for a failure callback:
[
string]msg: the error message.
window.WindVane.call('WVUI', 'disableAlertBeforeUnload', {}, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});WVUIDialog.prompt
This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.
Enters text in the dialog that appears.
Input parameters
[
string]title: optional. The title of the prompt message.[
string]message: the text of the prompt message. The default parameter value is "Input the content".[
string]hint: optional. The prompt content in the input box.[
string]okbutton: the OK button in the confirmation message. Optional. The default value is "OK".[
string]cancelbutton: the Cancel button in the confirmation message. Optional. The default parameter value is "Cancel".
Callback parameters
Parameters for a success callback:
[
boolean]ok: If you click OK, true is returned. If you click Cancel, false is returned.[
string]inputValue: If you click OK, true and the content that you tap are returned.
Parameters for a failure callback:
[
string]msg: the error message.
var params = {
title: 'prompt message'
message: 'Enter xxx'
hint: 'Enter xxx'
okbutton: 'OK',
cancelbutton: 'Cancel'
};
window.WindVane.call('WVUIDialog', 'prompt', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});WVUIDialog.showAuthGuide
This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.
Enables the corresponding permissions on the dialog that appears in the image and text form through the permission guidance module.
Input parameters
[
string]permission: the text of the permission, such as "camera" and "address book".[
string]okbutton: the OK button in the confirmation message.[
string]jumpToSettings: specifies whether you are redirected to the app details page after you click the OK button. "0" indicates that you are not redirected to the app details page. "1" indicates that you are redirected to the app details page. The default value is "0". This parameter is optional.
Callback parameters
Parameters for a success callback:
No callback parameters exist.
Parameters for a failure callback:
[
string]msg: the error message.
var params = {
permission: 'Address book'
cancelbutton: 'Cancel'
};
window.WindVane.call('WVUIDialog', 'showAuthGuide', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});


