Javascript - 如何停止捏缩放,多点触摸输入攻击? [英] Javascript - How to stop pinch zoom, multi touch input attacks?

查看:160
本文介绍了Javascript - 如何停止捏缩放,多点触摸输入攻击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前Google chrome稳定版本已停止手动阻止缩放缩放,这可以在旧版本中使用以下设置:

  chrome: // flags /#enable-pinch 

我在一些随机捏放大/多点触摸输入。



如何判断JavaScript是否禁用缩放/多点触摸? (保护自助服务亭)



我尝试了以下方法,但没有任何东西可以阻止自助服务终端无视紧缩缩放攻击。

<$ ()函数(){
console()函数(){
$ b $(document).bind('contextmenu',function() ('NO NO NO。STOP !!!');
window.location.reload();
return false;
});

$(文件).mousedown(函数(){
console.log('NO NO NO。STOP !!!');
return false;
});

});

编辑:

chrome:// flags /#enable-pinch - 在Chrome浏览器中再也无法使用了。谷歌不应该删除它,社区应该抗议不要删除它。 >能够通过将此元标记添加到< head> 中来防止用户放大:

 < meta name =viewportcontent =width = device-width,user-scalable = no> 

我的Google Chrome版本版本51.0.2704.84(64位),当我在开发人员工具中使用其触摸仿真进行测试时,尊重此设置。



例如:


  1. 的网站可以通过捏:黑客新闻

< meta name =viewportcontent =width = device-宽度,初始缩放= 1.0>


  1. 不是可以缩放:设计师新闻


  2. $ b $ p $ lt; code>< meta name =viewportcontent =width = device-width,user-scalable = no>



    我想评论一下,允许用户放大或缩小不应该被视为攻击。放大对于视力不好的人来说非常重要(或者视力障碍者,我不确定英文术语是否正确和有礼貌)。

    如果你禁用自然缩放行为,您应该对网页的可读性承担全部责任。


    Current Google chrome stable version stopped manually blocking pinch zoom, which was possible in older versions with following settings:

    chrome://flags/#enable-pinch
    

    I am getting attacks in my kiosk from some random pinch zoom/multi touch inputs.

    How to tell JavaScript to disable pinch zoom/multi touch? (to protect the kiosk)

    I tried following but nothing is stopping the kiosk from ignore pinch zoom attacks.

    $(document).ready(function() {
    
      $(document).bind('contextmenu', function()  {
        console.log('NO NO NO. STOP!!!');
        window.location.reload();
        return false;
      });
    
      $(document).mousedown( function() {
        console.log('NO NO NO. STOP!!!');
        return false; 
      });
    
    });
    

    EDIT:

    chrome://flags/#enable-pinch - never works anymore in Google chrome. Google should not have removed it and community should have protested to not have it removed.

    解决方案

    You should be able to prevent users from zooming in by adding this meta tag to your <head>:

    <meta name="viewport" content="width=device-width, user-scalable=no">
    

    My version of Google Chrome Version 51.0.2704.84 (64-bit), respects this setting when I test it using its touch emulation in the developer tools.

    For example:

    1. A website that is zoomable by pinching: Hacker News

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    1. A website that is not zoomable by pinching: Designer News

    <meta name="viewport" content="width=device-width, user-scalable=no">

    I would like to comment that allowing your users to zoom in and out shouldn't be considered an "attack". Zooming in is very important for people with bad eye sight (or the visually impaired, I'm not sure what the correct and polite English term would be).

    If you disable the natural zoom behavior, you should take full responsibility for the readability of your web page.

    这篇关于Javascript - 如何停止捏缩放,多点触摸输入攻击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆