x-y-z-select
x-y-z-select

Reputation: 95

Dissable javascript in media query

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
}

Upvotes: 0

Views: 122

Answers (2)

Idan Magled
Idan Magled

Reputation: 2216

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

this will help you

Upvotes: 0

Yair Nevet
Yair Nevet

Reputation: 13003

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');

Upvotes: 2

Related Questions