简体   繁体   English

在移动版本上禁用外部脚本

[英]Disable external script on mobile version

So I used an external script for my web page by所以我为我的网页使用了一个外部脚本

<script src="fullpage.js"></script>

But it disables scrolling on the site.但它禁用在网站上滚动。 On mobile version (which is completely different) I need to disable the script to make scrolling work.在移动版本(完全不同)上,我需要禁用脚本才能使滚动工作。 How can I do this?我怎样才能做到这一点?

you need first to detect if the user is browsing from mobile or not so you can use this method您首先需要检测用户是否正在从手机浏览,以便您可以使用此方法

function isMobileDevice() {
    return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1);
};

then you can wrap your script in the file with an if statement然后您可以使用 if 语句将脚本包装在文件中

// inside your fullpage.js file

if (!isMobileDevice()) { // check if it's not a mobile device
    // put your code here
}

I hope this helps :)我希望这有帮助 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM