Hello,

I found a lot of so called ajax (jquery) solutions to protect mailto's, but i found them still quite tricky. They used [mailto]test[at]domain[dot]com and then jquery to convert it to mailto:test@domain.com.
But i don't think it's that safe.

Now, what i want to do is to call a javascript function with the ID of the contact person, in this case 5414, (<a onClick="mailtofunction('5414')">click to mail me</a>). In the function i would like to make an ajax call to retrieve the email address from the database (not too difficult so far), and then generate a mailto link without refreshing the page.
Is this possible? Anybody has an idea?
I think this would be the perfect save solution.. no?

Thanks a lot for any help,

Mark

Recommended Answers

All 3 Replies

Use javascript instead of ajax, b/c people can get that ajax callback:
<span id="emailme">m^y&email|@|w(h)a(*)tever`n3et</span>
<script type="text/javascript">
window.onload=showEmails();
function showEmails(){
var email = document.getElementById('emailme').innerHTML + '';
emailFinal = email.replace(/[^A-Za-z@`]/,'').replace(/`/,'.');
document.getElementById('emailme').innerHTML = '<a href="mailto:'+emailFinal+'">'+emailFinal+'</a>';
}
</script>
I think that would be the best. It also might be nice to put in the output, instead of emailFinal, an image, so when people click the image, they can email you, and if they don't have javascript they can see the image. (see AFIfoam's Site for an example.)

Hello,

I'm not too good in regex, how do you print m^y&email|@|w(h)a(*)tever`n3et, or what does the regex do?
Thanks,

Mark

All the regex does is strip out any symbols, that aren't charaters, or the @ sign and the dots.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.