gpt4 book ai didi

javascript - 隐藏在phonegap中启动的软键盘android应用程序

转载 作者:行者123 更新时间:2023-12-03 03:28:05 24 4
gpt4 key购买 nike

我正在开发phonegap应用程序,遇到了一些小问题,并尝试了一切,但没有任何效果。

我已经在 Android 和 Iphone 中构建了应用程序,但我仅在 Android 中遇到问题。软键盘在应用程序启动时自动显示。

下面是我的 html 代码:-

<body>
<div id="page-transitions">
<div class="header header-logo-center header-dark">
<!-- <a href="#" class="header-icon header-icon-1 hamburger-animated open-sidebar-left"></a> -->
<a href="index.html" class="header-logo"></a>
<!-- <a href="#" class="header-icon header-icon-4 open-sidebar-right"><i class="ion-ios-email-outline"></i></a> -->
</div>

<div id="page-content" class="page-content">
<div id="page-content-scroll">
<!--Enables this element to be scrolled -->
<div class="page-fullscreen vertical-bg-3">
<div class="page-fullscreen-content">
<div class="pageapp-login">

<div class="pageapp-login-input animate-fade">
<i class="login-icon ion-person"></i>
<input id="username" type="email" value="Username" onfocus="if (this.value=='Username') this.value = ''" onblur="if (this.value=='') this.value = 'Username'">
</div>
<div class="pageapp-login-input animate-fade animate-delay-100">
<i class="login-icon ion-asterisk"></i>
<input id="password" type="password" value="Password" onfocus="if (this.value=='Password') this.value = ''" onblur="if (this.value=='') this.value = 'Password'">
</div>
<div class="pageapp-login-links">
<!-- <a href="#" class="page-login-forgot"><i class="ion-ios-eye"></i>Forgot Credentials</a> -->
<a href="page-register.html" target="_self" class="page-login-create animate-right">Create Account<i class="ion-person"></i></a>
<div class="clear"></div>
</div>
<button id="btnSubmit" class="button button-green button-icon button-full half-top full-bottom animate-zoom"><i class="ion-ios-arrow-thin-right"></i>Login</button>

</div>
</div>
<div class="overlay dark-overlay"></div>

</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {

}).on('deviceready', function () {
document.addEventListener("deviceready",
checkExistingSession, false);
});

js 代码将在设备就绪事件上加载并重定向到另一个页面

  function checkExistingSession() {

var userName = localStorage.getItem("username");
var password = localStorage.getItem("password");
var deviceType = localStorage.getItem("deviceType");
var deviceToken = localStorage.getItem("deviceToken");

var parameter = {
"username": userName,
"password": password,
"deviceType": deviceType,
"deviceToken": deviceToken
}

if (userName != null && password != null) {
$.ajax({
url: api_baseUrl + 'login',
type: "post",
data: JSON.stringify(parameter),
dataType: "json",
success: function (response) {
// Inserting html into the result div on success

if (response !== null && response.status === 1) {
window.location = "dashboard.html";
}
else {
window.location = "index.html";
return false;
}
}
});
}

}

</script>
</body>

最佳答案

您需要安装keyboard plugin .

cordova plugin add cordova-plugin-keyboard

现在,在设备就绪事件中隐藏键盘。

Keyboard.hide();

编辑 1 :-

尝试在 androidmanifest.xml 中添加这一行

android:windowSoftInputMode="stateHidden|adjustPan"

希望这可能有所帮助。

关于javascript - 隐藏在phonegap中启动的软键盘android应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46220462/

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