user5592459
user5592459

Reputation:

Block Zoom of a Web-based Project in a Touchable Screen

I am developing a Web-based project that runs on a Localhost that needs to block the zoom of the user interface on it. Is there any way to block this using JavaScript? In addition, can I block this using only Google Chrome?

I know it is not a good practice to do so, but in this case is not that important. Mostly, due to the fact that the only Human-Interaction Tool in this desktop App is a touchable screen and there is a requirement to block the Zoom of it.

Upvotes: 3

Views: 36

Answers (1)

SBoys3.com
SBoys3.com

Reputation: 424

you could use the code

<script>
(function(){
setInterval("document.body.style.zoom=1/window.devicePixelRatio",0);
var newview=document.createElement("meta");
newview.id="viewport";
newview.name="viewport";
newview.content="width=device-width, initial-scale=1";
document.body.parentElement.children[0].appendChild(newview);
})()
</script>

Add a comment if you have any questions or problems with this.

Upvotes: 1

Related Questions