[英]Obfuscating Email addresses with Javascript - split - reverse - join (Beginner)
Thank you for your time.感谢您的时间。
I'm trying to build a simple script to reverse email addresses as strings so I can use them for visible email addresses, email mailto: links & addresses for the "action" parameter in forms etc... to help avoid simple scraper bots. I'm trying to build a simple script to reverse email addresses as strings so I can use them for visible email addresses, email mailto: links & addresses for the "action" parameter in forms etc... to help avoid simple scraper bots.
I've tried a multitude of different methods and I'm probably just too inept at js to get them working.我尝试了多种不同的方法,但我可能对 js 太无能,无法让它们正常工作。 Here's a partially working sample of what I think would be an ideal situation.这是我认为理想情况的部分工作示例。
The data I want does show up in the console log but I'm having trouble getting it to show up in any of the html.我想要的数据确实显示在控制台日志中,但我无法让它显示在任何 html 中。 Any help would be greatly appreciated.任何帮助将不胜感激。
<script> var contact = "moc.etis@tcatnoc"; function reverseString(str) { return str.split('').reverse().join(''); document.getElementById('showemail').innerHTML = 'contact'; } console.log(reverseString(contact)); </script> <span id="showemail"></span> <a href="javascript:reverseString('contact');"> Contact </a> <a href="javascript:void(0);" onload="reverseString(contact);"> Contact </a>
I don't understand the question, but if i try to run the code i have as output 'contact'(reversed).我不明白这个问题,但如果我尝试运行我拥有的代码 output 'contact'(反向)。 Are you wondering how to print the original string?您想知道如何打印原始字符串吗?
In that case i think will work ->在那种情况下,我认为会起作用->
var contact = "moc.etis@tcatnoc";
function reverseString(str) {
return str.split('').reverse().join('');
document.getElementById('showemail').innerHTML = contact;
}
console.log(reverseString(contact));
</script>
<span id="showemail"></span>
<a href="javascript:reverseString(contact);"> Contact </a>
<a href="javascript:void(0);" onload="reverseString(contact);"> Contact </a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.