登录页面-防止软键盘弹出所引起的定位问题

This commit is contained in:
gongjin
2018-04-17 14:54:59 +08:00
parent 119dc13488
commit d07c77ebf9
8 changed files with 75 additions and 41 deletions
+16 -13
View File
@@ -12,7 +12,9 @@
<link rel="stylesheet" href="../../css/sm.css">
<link rel="stylesheet" href="../../css/main.css">
<link rel="stylesheet" href="../../css/theme-orange.css">
<style>
html,body{height:auto;}
</style>
</head>
<body>
@@ -120,18 +122,19 @@ function openView() {
clicked(BASE_PATH + '/user/agreement',true)
}
var originalHeight=document.documentElement.clientHeight || document.body.clientHeight;
window.onresize=function(){
//软键盘弹起与隐藏 都会引起窗口的高度发生变化
var resizeHeight=document.documentElement.clientHeight || document.body.clientHeight;
if(resizeHeight*1<originalHeight*1){ //resizeHeight<originalHeight证明窗口被挤压了
if(window.viewsPage=="codeSms"){
plus.webview.currentWebview().setStyle({
height:originalHeight
});
}
}
}
/* 防止软键盘弹出所引起的定位问题 */
var winHeight = $(window).height(); // 获取当前页面高度
$(window).resize(function(){
var thisHeight = $(this).height();
if(winHeight - thisHeight > 50){
//当软键盘弹出,在这里面操作
$(".loginMode").hide();
}else{
//当软键盘收起,在此处操作
$(".loginMode").show();
}
});
</script>
</body>