繁体   English   中英

从javascript检测浏览器自动完成设置

[英]Detect Browser autocomplete settings from the javascript

有什么办法可以从客户端脚本检测自动完成的浏览器设置? 不同的浏览器具有差异自动完成设置。

我想基于自动完成功能的客户端浏览器设置将autocomplete =“ off”添加到文本字段。

你为什么不谷歌它我的朋友.....

http://help.dottoro.com/ljdwgiwh.php

Example Code:

在用户名和城市字段中填写一些文本内容,然后提交表单。
之后,开始用相同的内容填充这些字段。 将为用户名字段显示一个自动完成窗口。

  <head>
    <script type="text/javascript">
        function DisableAutoComp () {
            var username = document.getElementById ("username");
            if ('autocomplete' in username) {
                username.autocomplete = "off";
            }
            else {
                    // Firefox
                username.setAttribute ("autocomplete", "off");
            }
        }
    </script>
</head>
<body>
    Fill the user name and city fields with some text content, and submit the form.<br />
    After that, start to fill these fields with the same content. An autocomplete window will displayed for to the user name field.
    <br /><br />
    <form method="post" action="#URL#">
        User name, with autocompletion:
        <input type="text" id="username" name="username" autocomplete="on" />
        <br />
        City, without autocompletion:
        <input type="text" name="city" autocomplete="off" />

        <br /><br />
        <input type="submit" value="Send" />
    </form>
    <br />
    <button onclick="DisableAutoComp ();">Disable autocompletion!</button>
</body>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM