当前位置:首页>>问题

卧首

卧首工作室专业从事软件设计开发、小程序制作、网站开发制作、托管维护等相关业务。我们是一支年轻的队伍,知识强,实战经验丰富,客户案例众多。自工作室成立以来,我们以质量求生存,以服务求发展,使客户得到称心满意的一条龙服务 。

js判断电脑端或者手机端

<script>functionisMobile(){//判断是否为移动设备return(typeofwindow.orientation!=="undefined"||//判断是否存在window.orientation属性,此属性在移动设备上一般存在navigator.userAgent.index

admin
<script>
        function isMobile() {
            // 判断是否为移动设备
            return (
                typeof window.orientation !== "undefined" || // 判断是否存在window.orientation属性,此属性在移动设备上一般存在
                navigator.userAgent.indexOf('IEMobile') !== -1 || // 判断是否为Windows Phone
                navigator.userAgent.indexOf('iPhone') !== -1 || // 判断是否为iPhone
                navigator.userAgent.indexOf('Android') !== -1 && navigator.userAgent.indexOf('Mobile') !== -1 || // 判断是否为Android手机
                navigator.userAgent.indexOf('BlackBerry') !== -1 || // 判断是否为BlackBerry
                navigator.userAgent.indexOf('Opera Mini') !== -1 // 判断是否为Opera Mini浏览器
            );
        }

        if (isMobile()) {
            console.log('移动端');
            document.getElementById('wanfa').style.display='none';
        } else {
            console.log('PC端');
            document.getElementById('wanfa').style.display='block';
        }
</script>


返回顶部