0

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

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by codejoust
0

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.)

0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.