我是
javascript的新手,我想掩盖js中的电子邮件ID
像mynewemail@gmail.com一样掩盖为m********l@gmail.com.我如何在js中实现.我的下面的代码不适用于浏览器
var maskid = ""; var myemailId = "mynewemail@gmail.com"; var prefix= myemailId .substring(0,myemailId .lastIndexOf("@")); var postfix= myemailId .substring(myemailId .lastIndexOf("@")); for(var i=0; i<prefix.length; i++){ if(i == 0 || i == prefix.length-1 ) { maskid = maskid + prefix[i].toString(); } else { maskid = maskid + "*"; } } maskid =maskid +postfix;
我想在JS中处理是必需的.
谢谢