/
index.html
34 lines (34 loc) · 1.04 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Detect if a Media Query is being used or not</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script>
var detect_mq = {
live: true, // Boolean: Trigger on window resize, true or false
threshold: 200, // Integer: Threshold time after window resize, in milliseconds
callback: function () {
var element = document.getElementById("which");
// If narrow layout
if (dmq_size == "narrow") {
element.innerHTML = dmq_size;
}
// If normal layout
if (dmq_size == "normal") {
element.innerHTML = dmq_size;
}
// If wide layout
if (dmq_size == "wide") {
element.innerHTML = dmq_size;
}
}
};
</script>
<script src="detectMQ.js"></script>
</head>
<body>
<h1>Media query ‘<span id="which">narrow</span>’ in use.</h1>
</body>
</html>