0

I use some JavaScript in my menu when user scroll my webpage. Here is example

All works fine but i want to dissable that effect in media query. Can i disasbel JavaScript in media query ..

@media only screen
 (max-device-width : 360px) {
//dissable JavaScript
}
x-y-z-select
  • 87
  • 2
  • 9

2 Answers2

2

Can i disasbel JavaScript in media query ..

No, you can't, neither with CSS Media rule nor with any other programming mechanism. JavaScript activation is a matter of the user preferences in the web-browser.

But you can always use workarounds like this one: how to disable javascript for responsive design

Update:

You can easily test the current CSS media type using jQuery and accordingly to activate your JS code:

var media = $('link[href$="yourStyleFile.css"]').attr('media');
Community
  • 1
  • 1
Yair Nevet
  • 12,725
  • 14
  • 66
  • 108
0

you cant disable JavaScript, but you can detect the resolution and not write the JavaScript.

this will help you

Community
  • 1
  • 1
Idan Magled
  • 2,186
  • 1
  • 23
  • 33