In the past we’ve talked about how to add a print button to your WordPress theme. Today I wanted to give you the javascript code you need to create an Email This button on your WordPress blog.
Before getting to the code, I wanted to first say that this code is designed to allow readers to click on the button and have it open up their default email software and create a subject and link that point to the post the reader is currently visiting. This code is not designed to allow readers to contact the blog author.
If you are wanting your readers to be able to contact you, I recommend you use one of the many great contact form WordPress plugins available. You should never embed your email address into some HTML code because it will be picked up by spam bots. Contact forms prevent spammers from finding your email address. The other thing you can do is offer “EmailAddress AT EmailCompany DOT com” (which your email address information filled in) to avoid spammers.
Okay, so back to the Email button code. Here is the javascript you will need:
<script type="text/javascript">
<!-- Begin
function isPPC() {
if (navigator.appVersion.indexOf("PPC") != -1) return true;
else return false;
}
if(isPPC()) {
document.write('<a class="contact" HREF=\"mailto:\?subject\=Take a look at this page I found, ' + document.title + '?body=You can see this page at: ' + window.location + '\" onMouseOver="window.status=\'Send your friends e-mail about this page\'; return true" TITLE="Send your friends e-mail about this page">Email to a Friend<\/a>');
}
else { document.write('<a class="contact" HREF=\"mailto:\?body\=Take a look at this page I found titled ' + document.title + '. You can see this page at: ' + window.location + '\" onMouseOver="window.status=\'Send your friends e-mail about this page\'; return true" TITLE="Send your friends e-mail about this page" rel="nofollow">Email This!<\/a>');
}
// End -->
</script>
This will create an email where the reader can enter in someone’s email address and send them a link to your post/page.














There Are 28 Responses So Far »
Pingback: Fatih Hayrio?lu'nun not defteri » 04 Haziran 2008 web’den seçme haberler » Yeni, ç?kacak, taray?c?lar?n?n, kar??la?t?rmas?, Ba?lant?, Günlü?ümüze, Buradaki, epostalar?, Taray?c?lar, için
Pingback: Collection of WordPress Hacks
Pingback: Wordpress Hacks, Guides and Tricks | TechnoBuzz.net
Pingback: WordPress ?? ??? ??? snippet
Pingback: Top 30 Most Wanted Wordpress Tricks and Hacks | Make Money Blogging Experiment
Pingback: 50 Wordpress Resources that are Guaranteed to Improve Your Blog! | MattFlies.com