detect-zoom
detect-zoom copied to clipboard
Idea check the client width of a known Element
Has anyone thought of this?
<div id="test">H</div><br/>
<div id="content" style="background-color:cyan; width:50%;">BLAH<div/>
</body>
<script>
function work(){
var w = screen.width;
var content = document.getElementById("content");
var width = content.clientWidth;
var height = content.clientHeight;
document.getElementById("test").innerHTML = width + " " + height + " " + w;
}
setInterval(work,60);
</script>
var w doesn't change it's value when the page is zoomed. var width changes.
Some Maths and voila :smile:
unfortunately, screen.width
updates as you zoom in Firefox for one.