Ivan Miljkovic
Ivan Miljkovic

Reputation: 15

Disable jquery script for mobile devices

I would like to disable following script when the website is opened in mobile device, because i don't want unnecesary animations:

<script src="js/eskju.jquery.scrollflow.js"></script>

In HTML this script works with these classes:

<div class="scrollflow -slide-right -opacity">
//some code...
</div>

I'm begginer, and I have little knowledge about JavaScript. Thanks in advance.

Upvotes: 0

Views: 3310

Answers (1)

Henry Tran
Henry Tran

Reputation: 526

Add an ID to this script:

<script src="js/eskju.jquery.scrollflow.js" id="scScrollFlow"></script>

Add this javascript code at the bottom of your BODY:

if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/i.test(navigator.userAgent)) {
    $('#scScrollFlow').remove();
}

Update: I have tested it for you. This following solution will work fine:

First, open your file eskju.jquery.scrollflow.js, find and remove this code:

$( document ).ready( function()
        {
            new ScrollFlow();
        }); 

Add this javascript code to your site:

<script>
$( document ).ready( function()
{
    if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/i.test(navigator.userAgent) == false) {
        new ScrollFlow();
    }
});
</script>

Upvotes: 1

Related Questions