微信键盘弹出底部消失的兼容性写法

2019-01-03  本文已影响0人  yiqian091

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();

    });

}

上一篇下一篇

猜你喜欢

热点阅读