HomeDocs
Skip to main content

dlt.enableAlertBeforeUnload

Introduction

Enables the confirmation dialog that appears when leaving a page in the mini-program.

Conditions for the Dialog

  • When the user is on a non-homepage page within the mini-program
  • When using the official navigation bar's "Back" button
  • When using a custom back button in full-screen mode
  • When pressing the Android system's back button

Important Notes

  • The gesture-based back navigation is not intercepted.
  • In any scenario, this feature should not prevent users from exiting the mini-program.

Parameters

Object object

PropertyTypeDefaultRequiredDescription
messageStringYesConfirmation dialog message

Sample Code

Page({
onReady() {
dlt.enableAlertBeforeUnload({
message: 'Are you sure you want to leave?',
success: function (res) {},
fail: function (res) {},
complete: function (res) {},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.