Degrading -webkit-text-security

前端 未结 1 730
时光取名叫无心
时光取名叫无心 2020-12-03 12:03

NOTICE: If you are intereseted on implementing text-security feautures, I\'ve developed a jQuery plugin to accomplish this.

I\'m using text-se

相关标签:
1条回答
  • 2020-12-03 12:57

    This was pretty quick and dirty but it works.

    <html>
    <head>
        <style>
            input{
                -webkit-text-security:square; 
                text-security:square;
            }       
        </style>
    
        <script>
            window.onload = function(){
                init(); 
            }
            function init(){
                var x = document.getElementsByTagName("input")[0];
                var style = window.getComputedStyle(x);
                console.log(style);
                if(style.webkitTextSecurity){
                    //do nothing
                }else{
                    x.setAttribute("type","password");
                }
            }           
        </script>
    </head>
    <body>
        <div id="di">
            <input/>        
        </div>
    </body>
    

    Tested in chrome and firefox, I'm on linux so I can't test in IE. Jsfiddle here.

    0 讨论(0)
提交回复
热议问题