我希望公开页面上显示的电话号码得到保护。例如,将电话号码字符转换为HTML实体,使机器人无法以纯文本形式获取该号码。请告诉我这个技巧。
(Note: I have retained the HTML tags in the translated text as requested.)我希望公开页面上显示的电话号码得到保护。例如,将电话号码字符转换为HTML实体,使机器人无法以纯文本形式获取该号码。请告诉我这个技巧。
(Note: I have retained the HTML tags in the translated text as requested.)这只是一个想法,虽然我不确定它有多实用:
<span class="protectedNumber" title="01234567890"></span>
CSS:
span.protectedNumber:before {
content: "Phone number: " attr(title);
}
编辑:回应评论中的“跨浏览器?”问题,添加了jQuery选项,以协助那些不能处理CSS生成内容的浏览器。
$(document).ready(
function(){
$('.protectedNumber').each(
function(){
$(this).text('Phone number: ' + $(this).attr('title'));
});
});
一些想法
尝试使用ASCII编写数字: http://www.ascii.cl/htmlcodes.htm
<html>
<body>112</body>
</html>
当然可以用文字而不是数字打印电话号码...