方法一:浏览器
var win_h = $(window).height();//关键代码 window.addEventListener('resize', function () { if($(window).height() < win_h){ $('.share-btn-box').hide(); }else{ $('.share-btn-box').show(); } });
方法二:ide
//navigator.userAgent.indexOf用来判断浏览器类型 var isAndroid = navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1; if (isAndroid){//若是是安卓手机的浏览器 var win_h = $(window).height();//关键代码 $("body").height(win_h);//关键代码 window.addEventListener('resize', function () { // Document 对象的activeElement 属性返回文档中当前得到焦点的元素。 if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') { if($('.share-btn-box').is(':visible')){ $('.share-btn-box').hide(); }else{ $('.share-btn-box').show(); } } }); }