gpt4 book ai didi

javascript - WL.App.overrideBackButton 不起作用

转载 作者:行者123 更新时间:2023-11-30 01:37:25 26 4
gpt4 key购买 nike

我正在使用 IBM Mobilefirst Platform 7.1。我正在尝试覆盖 Android 中后退按钮的标准行为。我创建了新的 Mobilefirst 项目“Hello Mobilefirst”。在 ma​​in.js 中,我覆盖了后退按钮功能。我在 Samsung Note 4 上运行该应用程序,然后按后退按钮仅关闭该应用程序而不显示消息。如果我使用 alert 而不是 WL.SimpleDialog.show 应用程序显示消息,但之后它关闭应用程序。如何仅在按 YES 时关闭应用程序?

index.html

<body style="display: none;">
Hello MobileFirst
<script src="js/initOptions.js"></script>
<script src="js/main.js"></script>
<script src="js/messages.js"></script>
</body>

ma​​in.js

function wlCommonInit(){

}

WL.App.overrideBackButton(checkQuit());

function checkQuit() {
WL.SimpleDialog.show(
"Quit application",
"Are you sure?",
[
{text: "Yes", handler: function() {WL.App.close();}},
{text: "No", handler: function() {}}
]
);
}

谢谢!

最佳答案

首先需要找到客户端环境,在main.js文件中写入如下代码。

if(WL.Client.getEnvironment().toUpperCase() == "ANDROID"){
WL.App.overrideBackButton(backFunc);
}
function backFunc() {
// alert('You will back to previous page');
}

关于javascript - WL.App.overrideBackButton 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34954665/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com