Email ids shown in webpages like hello@domain.com or hello [at] domail.com were easily crackable using simple regex.
Spam programmers were always smarter than programmers. Aren’t they ?
The below shown 3 options is an attempt to avoid spammers scripts to read your email id.
Option 1:
Clicking the word ‘My email id‘ will open default email program with the to email id and subject filled in.
Copy and paste the below script inside head tag
<SCRIPT type="text/javascript"> function email(user, domain, ext, subject) { location.href = 'mailto:' + user + '@' + domain + '.' + ext + '?subject=' + subject; } </SCRIPT>
and call the function email as shown by the template below.
<a href="javascript:email('balajidl','javaranch','com','hello there..');">My email id</a>
Option 2:
Use the below script to write your email id directly on webpage. The advantage is its visible to human eyes but hard to read by spammers scripts.
<script type="text/javascript"> //<![CDATA[ document.write("<a href='mailto:balajidl"); document.write("@javaranch.com'>"); document.write("balajidl"); document.write("@"); document.write("javaranch."); document.write("com"); //]]> </script>
Option 3: Start thinking whether you want to display your emailid or not. 😉
Hi Balaji,
I tried option one. I did exactly as it has been said here in my blogger. I am getting the link, but when I click the link its NOT opening the outlook express.
With option two it’s not even showing up any link.
I appreciate your help here.
Hi Vishnu,
Few things you can test further
1. Does your browser opens outlook express if you click email id’s from this particular blog page or even other websites ?
2.For option1, try to alert the input variable before calling location.href and tell whether it is meaningfull for javascript. Something like alert(‘mailto:’ + user + ‘@’ + domain + ‘.’ + ext + ‘?subject=’ + subject);
3.For option 2: its a simple code that should work in standards browsers, unless javascript is disabled.
4.if nothing works, please drop a post at html forum of javaranch, folks there will certainly help you.
Let me know how it goes ??
Thank you. – Balaji
Hi Balaji,
Thanks for replying.
1. Does your browser opens outlook express if you click email id’s from this particular blog page or even other websites ?
No problems with the browser. I am using the latest version of Firefox Browser. when I click ‘My email id'(from your blog) it opens outlook express with your javarnch ID and with Subject “hello there..”
I tried the following code in my blog and when I click the link it opens the outlook express.
a href=”mailto:vp17in@gmail.com”> Email Me /a
2. For option1, try to alert the input variable before calling location.href and tell whether it is meaningfull for javascript. Something like alert(‘mailto:’ + user + ‘@’ + domain + ‘.’ + ext + ‘?subject=’ + subject);
Is it some thing like the below code. This too isn’t working. I am using blogspot(blogger).
3. For option 2: its a simple code that should work in standards browsers, unless javascript is disabled.
Yes of course it is working from your blog, but when I try to do it in my blog it isn’t.
Thank you. – Vishnu
Hi Vishnu,
Guess blogspot is not allowing to execute script from blog entries.
The simple hack could be to copy and paste the script tag between the head tag of your template.
Go to settings page of your blog, then click Template. You will get an editable textbox, add the option script between the head tags. Save it and republish your blog.
Now simply add the line <a href=”javascript:email..”>.. part inside your blog. This will call the email function.
You can see a working sample at http://balajidl.blogspot.com/ under the topic file extensoin check, click My email id.
Regards
Balaji
Hi Balaji
Thanks for your kind reply
Got it working
Cheers
many companys send adds in my id
how to protect my spam of this type of adds
please tellme solution
thankyou