Search code examples
htmlgoogle-chromewebkitzooming

How to detect zoom event and set zoom in Chrome on current page programmatically?


Chrome can be zoomed in or out by pressing Ctrl + + or - (Windows).

And I also noticed that some webpages can detective if current page is zoomed or not.

How do they get that good and is there any Webkit or HTML5 API can zoom Chrome on current page programmatically?


Solution

  • In css:

    zoom: 150%
    

    Appply this css property to body

    Or in js

    $(document.body).css('zoom','150%')
    

    To catch zoom event there are several techics ( check zoom on 'resize' for example ) - check this topic Catch browser's "zoom" event in JavaScript