How to detect page zoom level in all modern browsers?

后端 未结 28 1847
慢半拍i
慢半拍i 2020-11-21 05:27
  1. How can I detect the page zoom level in all modern browsers? While this thread tells how to do it in IE7 and IE8, I can\'t find a good cross-browser solution.

28条回答
  •  你的背包
    2020-11-21 06:09

    What i came up with is :

    1) Make a position:fixed

    with width:100% (id=zoomdiv)

    2) when the page loads :

    zoomlevel=$("#zoomdiv").width()*1.0 / screen.availWidth
    

    And it worked for me for ctrl+ and ctrl- zooms.

    or i can add the line to a $(window).onresize() event to get the active zoom level


    Code:

    
    
        

    P.S. : this is my first post, pardon any mistakes

提交回复
热议问题