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

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

    });

}

你可能感兴趣的:(微信键盘弹出底部消失的兼容性写法)