Menu icon Foundation
Javascript media queries?

Hi! Is there a simple way to detect media queries in javascript?

It would be nice one or more of the following:

- body or html auto-filled with current mq, so one can use for example body.large, body.medium, etc..

- a js event broadcasted on every mq change, so one can hook up and do something. For example,

Foundation.on('mqchange',function(event_obj, current_mq){
//if(current_mq == "large") do this... else...
});

or

Foundation.on('mq_small',function(event_obj){
//do small screens stuff....
});

thank you!

media queriesjavascript

Hi! Is there a simple way to detect media queries in javascript?

It would be nice one or more of the following:

- body or html auto-filled with current mq, so one can use for example body.large, body.medium, etc..

- a js event broadcasted on every mq change, so one can hook up and do something. For example,

Foundation.on('mqchange',function(event_obj, current_mq){
//if(current_mq == "large") do this... else...
});

or

Foundation.on('mq_small',function(event_obj){
//do small screens stuff....
});

thank you!

This post has been closed. No new replies can be added.

Luca Reghellin almost 6 years ago

Oooookey. Thank you!