Javascript - Ẩn địa chỉ email
Ẩn địa chỉ email
Viết một hàm JavaScript để ẩn địa chỉ email để bảo vệ người sử dụng.
Mã nguồn:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JavaScript program to convert the letters of a given string in alphabetical order.</title>
</head>
<script>
protect_email = function (user_email) {
var avg, splitted, part1, part2;
splitted = user_email.split("@");
part1 = splitted[0];
avg = part1.length / 2;
part1 = part1.substring(0, (part1.length - avg));
part2 = splitted[1];
return part1 + "...@" + part2;
};
document.write(protect_email("robin_singh@example.com"));
</script>
<body>
</body>
</html>
Lưu đồ thuật toán:


