禁用手机脚本 [英] disable script for mobiles

查看:142
本文介绍了禁用手机脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,在手机上打开时,我必须禁用视差效果脚本. 我发现了一个与我想要和修改的脚本相似的脚本,但是它不起作用.有人知道怎么了吗?

HI friends I have to disable script for parallax effects when open on mobile phones. I found a script similar to what I wanted and adapted, however it does not work. Anyone know what's wrong?

var isMobile = {
    Android: function() {
        return navigator.userAgent.match(/Android/i);
    },
    BlackBerry: function() {
        return navigator.userAgent.match(/BlackBerry/i);
    },
    iOS: function() {
        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
    },
    Opera: function() {
        return navigator.userAgent.match(/Opera Mini/i);
    },
    Windows: function() {
        return navigator.userAgent.match(/IEMobile/i);
    },
    any: function() {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
    }
};

jQuery(document).ready(function(){
if( !isMobile.any()){
    $(window).stellar(): false;
    }
});

推荐答案

jQuery(document).ready(function(){
if( !isMobile.any()){
    $(window).stellar(): false;
    }
});

第三行在语法上是错误的.您到底想用
fn(): false;之类的东西来实现什么?

That third line is syntactically wrong. What exactly are you trying to achieve with something like
fn(): false;?

我相信您正在寻找:

jQuery(document).ready(function(){
    if( !isMobile.any() ){
        $(window).stellar();
    }
});

换句话说:仅当!isMobile.any()应该执行$(window).stellar()时.在其他情况下(isMobile.any()true),不应执行if块.

In other words: only if !isMobile.any() should $(window).stellar() be executed. In the other case (where isMobile.any() is true), the if block should not be executed.

这篇关于禁用手机脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆