Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
ufo-app-web
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
陈峰
6 years ago
Commit
0accaa941a9b5bbf8e71bee5a40e04af98c840f1
2 parents
6cae6665
2b8acd04
Merge branch 'hotfix/fixinput' into 'master'
fix input See merge request
!14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
apps/index.html
doraemon/views/index.hbs
apps/index.html
View file @
0accaa9
...
...
@@ -88,6 +88,31 @@
s
.
parentNode
.
insertBefore
(
hm
,
s
);
})();
}());
function
isWeiXinAndIos
()
{
// window.navigator.userAgent属性包含了浏览器类型、版本、操作系统类型、浏览器引擎类型等信息,这个属性可以用来判断浏览器类型
let
ua
=
''
+
window
.
navigator
.
userAgent
.
toLowerCase
()
// 通过正则表达式匹配ua中是否含有MicroMessenger字符串且是IOS系统
let
isIos
=
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/i
.
test
(
ua
)
// 是IOS系统
return
isIos
}
(
function
()
{
let
myFunction
let
isWXAndIos
=
isWeiXinAndIos
()
if
(
isWXAndIos
)
{
// 既是微信浏览器 又是ios============(因为查到只有在微信环境下,ios手机上才会出现input失去焦点的时候页面被顶起)
document
.
body
.
addEventListener
(
'focusin'
,
()
=>
{
// 软键盘弹起事件
clearTimeout
(
myFunction
);
});
document
.
body
.
addEventListener
(
'focusout'
,
()
=>
{
// 软键盘关闭事件
clearTimeout
(
myFunction
)
myFunction
=
setTimeout
(
function
()
{
window
.
scrollTo
({
top
:
0
,
left
:
0
,
behavior
:
'smooth'
})
// 重点 =======当键盘收起的时候让页面回到原始位置
},
200
);
});
}
})();
</script>
</body>
</html>
...
...
doraemon/views/index.hbs
View file @
0accaa9
...
...
@@ -110,7 +110,32 @@
s.parentNode.insertBefore(hm, s);
})();
}());
function isWeiXinAndIos() {
// window.navigator.userAgent属性包含了浏览器类型、版本、操作系统类型、浏览器引擎类型等信息,这个属性可以用来判断浏览器类型
let ua = '' + window.navigator.userAgent.toLowerCase()
// 通过正则表达式匹配ua中是否含有MicroMessenger字符串且是IOS系统
let isIos = /\
(
i
[
^
;]
+
;(
U
;)?
CPU
.
+
Mac
OS
X
/
i
.
test
(
ua
)
// 是IOS系统
return
isIos
}
(
function
()
{
let
myFunction
let
isWXAndIos
=
isWeiXinAndIos
()
if
(
isWXAndIos
)
{
// 既是微信浏览器 又是ios============(因为查到只有在微信环境下,ios手机上才会出现input失去焦点的时候页面被顶起)
document
.
body
.
addEventListener
(
'focusin'
,
()
=>
{
// 软键盘弹起事件
clearTimeout
(
myFunction
);
});
document
.
body
.
addEventListener
(
'focusout'
,
()
=>
{
// 软键盘关闭事件
clearTimeout
(
myFunction
)
myFunction
=
setTimeout
(
function
()
{
window
.
scrollTo
({
top
:
0
,
left
:
0
,
behavior
:
'smooth'
})
// 重点 =======当键盘收起的时候让页面回到原始位置
},
200
);
});
}
})();
},
500
);
</script>
</body>
</html>
...
...
Please
register
or
login
to post a comment