显示隐藏键盘在android phonegap中不正常工作



我按照此链接使用[Simon mac donald Definition][1]来使用键盘事件。在该事件中,当键盘隐藏时,我显示我的页脚,当键盘显示时,我隐藏我的页脚。当单击dictionary时,我的keybord是显示,但事件转到键盘隐藏功能(因此显示我的脚注)。。我不知道为什么。。

我附上了我的代码和设计。请解决这个问题

   <script type="text/javascript">
    $(document).ready(function () 
    {
        document.addEventListener("hidekeyboard", onHide, false);
        document.addEventListener("showkeyboard", onShow, false);
    });
    function onHide() 
    {
        $("#footer").show();
    }
    function onShow() 
    {
        $("#footer").hide();
    }
    </script>
<style type="text/css">
#footer {
    position:absolute;
    bottom:0; left:0;
    width:100%;
    height:7%;
    background-color:#00458D;
    padding:0;
    border-width:3px;
    padding-top:3%;
    padding-bottom:2%;
    padding-right:0px;
    padding-left:0px;
    background-color:#00458D;
}
#content {
    position:absolute; bottom:0;
    top:0;
    width:100%;
    overflow:auto;
}
</style>
  </head>
 <body >
    <div id="content">
        <input type="text" style="width=70%">
            <br/>
            <br/>
        <div id="footer" align="center">
            <table width=100%>
                <input type="image" src="../images/Home.PNG" style="width:23%" onClick="home()"/>
                <input type="image" src="../images/messages-menu.jpg" style="width:23%" onClick="inbox()"/>
                <input type="image" src="../images/settings-menu.jpg" style="width:23%" onClick="settings()"/>
                <input type="image" src="../images/close-menu.png" style="width:23%" onClick="callServiceFunction()"/>
            </table>
        </div>
    </div>
  </body>
</html>

图像

删除.ready()函数并在设备就绪中添加侦听器

<style type="text/css">
#footer {
    position:absolute;
    bottom:0; left:0;
    width:100%;
    height:7%;
    background-color:#00458D;
    padding:0;
    border-width:3px;
    padding-top:3%;
    padding-bottom:2%;
    padding-right:0px;
    padding-left:0px;
    background-color:#00458D;
}
#content {
    position:absolute; bottom:0;
    top:0;
    width:100%;
    overflow:auto;
}
</style>
<script type="text/javascript">
document.addEventListener("deviceready",onDeviceReady,false);
    function onDeviceReady () {
        document.addEventListener("hidekeyboard", onHide, false);
        document.addEventListener("showkeyboard", onShow, false);
    }
    function onHide() 
    {
        $("#footer").show();
    }
    function onShow() 
    {
        $("#footer").hide();
    }
    </script>
  </head>
 <body >
    <div id="content">
        <input type="text" style="width=70%">
            <br/>
            <br/>
        <div id="footer" align="center">
            <table width=100%>
                <input type="image" src="../images/Home.PNG" style="width:23%" onClick="home()"/>
                <input type="image" src="../images/messages-menu.jpg" style="width:23%" onClick="inbox()"/>
                <input type="image" src="../images/settings-menu.jpg" style="width:23%" onClick="settings()"/>
                <input type="image" src="../images/close-menu.png" style="width:23%" onClick="callServiceFunction()"/>
            </table>
        </div>
    </div>
  </body>
</html>

在OndeviceReady()中试用

 $(document).ready(function () 
 {
      document.addEventListener("deviceready", onDeviceReady, false);
 }
 function onDeviceReady()
 {
     document.addEventListener("hidekeyboard", onHide, false);
     document.addEventListener("showkeyboard", onShow, false);
 }
 function onHide() 
 {
       $("#footer").show();
 }
 function onShow() 
 {
       $("#footer").hide();
 }

最新更新