+
95
-

js如何禁止用户进行网页缩放?

请问js如何禁止用户进行网页缩放?

网友回复

+
15
-

现在没办法绝对禁止用户缩放网页,但是可以增加一个有情提醒,比如当前网页缩放非100%,为了您的体验,请缩放至100%;

可以在用户进行缩放网页的时候进行提醒。

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" />
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript">
        function detectZoom (){
              var ratio = 0,
                screen = window.screen,
                ua = navigator.userAgent.toLowerCase();
               if (window.devicePixelRatio !== undefined) {
                  ratio = window.devicePixelRatio;
            
              }
            
              else if (~ua.indexOf('msie')) {
                if (screen.deviceXDPI && screen.logicalXDPI) {
                  ratio = screen.deviceXDPI / screen.logicalXDPI;
                }
     ...

点击查看剩余70%

我知道答案,我要回答