当光标聚焦在一个字段时,Phonegap返回按钮不工作
Phonegap back button not working when cursor focus on a field
我在我的应用程序javascript上重写backbutton事件,像这样:
document.addEventListener("backbutton", function (e) {
e.preventDefault();
navigator.app.backHistory();
}, false);
如果光标没有集中在任何元素,存在于webview (CordovaWebView),按后退按钮是好的,在我的情况下,它回到以前的活动。
但是,如果光标集中在字段表单上,例如输入字段或按钮,后退按钮不起作用或隐藏键盘。当我按下返回键时,日志只显示这个。
05-13 12:47:41.463: D/CordovaWebView(14396): The current URL is: file:///android_asset/www/login.html#register
05-13 12:47:41.463: D/CordovaWebView(14396): The URL at item 0 is:file:///android_asset/www/login.html#register
05-13 12:47:41.663: D/CordovaWebView(14396): The current URL is: file:///android_asset/www/login.html#register
05-13 12:47:41.663: D/CordovaWebView(14396): The URL at item 0 is:file:///android_asset/www/login.html#register
05-13 12:47:42.203: D/CordovaWebView(14396): The current URL is: file:///android_asset/www/login.html#register
05-13 12:47:42.203: D/CordovaWebView(14396): The URL at item 0 is:file:///android_asset/www/login.html#register
我已经尝试在DroidGap扩展上覆盖onBackPressed,但使其根本不起作用。
编辑
我忘了说,我用的是Backbone Router作为url状态
"backbutton"事件仅在按下按钮返回时触发,而在关闭键盘时不触发。
你能得到的最接近的是拦截由于键盘关闭而导致的窗口大小调整,并做出相应的反应:
$(document).ready(function() {
var curWindow = $(window);
var initialHeight = curWindow.height();
curWindow.resize(function() {
console.log("resize: height="+curWindow.height());
if (curWindow.height() == initialHeight) {
// TODO: Keyboard hidden!
}
});
});
相关文章:
- Phonegap-返回按钮重新加载整个页面
- Windows phone 8和phonegap 2.7.0,HTML页面和Xaml之间的导航以及返回
- PhoneGap API返回时间戳格式
- 如何在phonegap javascript函数中返回结果
- Native Phonegap、下载并创建文件、动态命名文件和返回路径
- Phonegap:监听页面并关闭InAppBrowser返回index.html的简单方法
- 为什么iOS上的Phonegap中的新日期不返回任何内容
- 执行带有 WHERE 子句的 Sql 在 Phonegap 中不返回任何结果
- 在 Phonegap DB 函数中返回函数外部的变量
- PhoneGap安卓应用程序需要获取外部SD卡路径,但它只返回内部SD卡路径
- 如何在phonegap android中从js向html页面返回值
- 返回到索引.html从图像.html通过使用PhoneGap Android中的“手机后退”按钮
- phonegap+iOS,http请求在本地文件上总是返回状态0
- 如何等待数据库事务完成它的操作并在phonegap中返回值
- 如何使用jquery在phonegap类上返回延迟对象
- phonegap Ajax调用在android设备中返回error=undefined
- Windows Phone PhoneGap应用返回按钮问题
- xmlhttpRequest状态在phonegap中返回0
- 当光标聚焦在一个字段时,Phonegap返回按钮不工作
- Facebook邀请在phonegap返回OK