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
}
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');
you cant disable JavaScript, but you can detect the resolution and not write the JavaScript.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.