detect-zoom icon indicating copy to clipboard operation
detect-zoom copied to clipboard

Idea check the client width of a known Element

Open Drtikso opened this issue 10 years ago • 1 comments

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:

Drtikso avatar Sep 03 '14 01:09 Drtikso

unfortunately, screen.width updates as you zoom in Firefox for one.

curiousercreative avatar Sep 19 '20 16:09 curiousercreative