微信h5页面ios系统,input聚焦后软件盘导致页面问题
1 情况一:出现白屏现象
下面代码是实现页面复制的功能,当没readOnly时,部分ios机在执行到aux.select()时出现页面出现页面上移,如果已经是底部,会多出半白屏(html配景致)。若给input添加readOnly属性后,软键盘导致页面位移的问题管理,但是readOnly会使document.execCommand(“copy”)在部分ios机型失效,重置滚动条位置会出现闪烁现象,使用clipboardjs举行复制功能。
- var aux = document.createElement("input"); aux.setAttribute("value", content); //aux.setAttribute("readOnly", true); document.body.appendChild(aux); aux.select(); //导致问题出现的原因 document.execCommand("copy"); aux.blur() document.body.removeChild(aux);
复制代码 2情况二:手动把软键盘收起后,页面结构正常,页面按钮实际位置上移。
当用户手动输入后隐藏软键盘后,页面结构正常,但是实际html的交互按钮,input输入框都出现了位置上移,管理方法是给input添加onblur事件,在input失去焦点时重置滚动条位置。
- function onblur() { window.scroll(0, 0)}
复制代码 来源:https://blog.csdn.net/jinxinlive/article/details/112008569
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |