1

I want to disable my .js file when a browser window is less than 1000px but I also want to disable it for specific devices / media queries.

So for example, I want to make sure it doesn't load on iPad.

I have got the 1000px part sorted but I am not sure how to also implement the media query?

<script>
$(function() {
var windowWidth = $(window).width();
if(windowWidth > 1000){
    skrollr.init({
        forceHeight: false
    });
}});
</script>
3

1 Answer 1

1

You need to detect the userAgent, as seen here : What is the best way to detect a mobile device in jQuery?

In your code :

<script>
        $(function() {
             var windowWidth = $(window).width();
          if(windowWidth > 1000 && !(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))){
           skrollr.init({
           forceHeight: false
          });
          }});
    </script>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks - This is exactly what I was trying to find!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.