微信鍵盤彈出底部消失的兼容性寫法

var u =navigator.userAgent;

var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;

var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);

if (isAndroid) {

// android監聽鍵盤彈起底部影藏

? ? var clientHeight =document.documentElement.clientHeight ||document.body.clientHeight;

? ? $(window).on('resize', function () {

var nowClientHeight =document.documentElement.clientHeight ||document.body.clientHeight;

? ? ? ? if (clientHeight > nowClientHeight) {

$('.footer').hide();

? ? ? ? }

else {

$('.footer').show();

? ? ? ? }

});

}

if (isiOS) {

// ios監聽鍵盤彈起底部影藏

? ? $(document).on('focusin', function () {

$('.footer').hide();

? ? });

? ? $(document).on('focusout', function () {

$('.footer').show();

? ? });

}

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容