•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 422,788 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,407 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 516 | Replies: 2
![]() |
| |
•
•
Join Date: Aug 2007
Posts: 52
Reputation:
Rep Power: 2
Solved Threads: 2
I've created a fairly simple method for obfuscating email addresses as an anti-spam measure. It should work for any browser that supports JavaScript and a fairly modern Document Object Model (DOM). A composer window in the user's default email application will be opened.
First up is the javascript function that assembles the mailto: url and 'submits' it: You should customize everything (but the script tags and function and self.location) to prevent spammers from learning to recognize the pattern. Even the order of the parameters should be customized.
Next up is the PHP function that eases using this method: An example of its use is: If you don't have access to PHP, then you can create the link directly in HTML. This is the same HTML generated by the PHP, except for whitespace::
First up is the javascript function that assembles the mailto: url and 'submits' it:
javascript Syntax (Toggle Plain Text)
<script language="javascript"> // Action taken when an email 'link' is clicked function local_emclick(parm1, parm2) { test_4 = "lto:"; d37 = "@"; t2 = "mai"; parm = t2+test_4+parm1+d37+parm2; self.location = parm; } </script>
Next up is the PHP function that eases using this method:
php Syntax (Toggle Plain Text)
function local_emlink($one, $two, $three, $four, $five="") { if ($five!="") { $smso = "<b>"; $rmso = "</b>"; } else { $smso = ""; $rmso = ""; } print("$smso<a class=\"$two\" href=\"about:\" onclick='local_emclick(\"$one\", \"$three\"); return false;'>$four</a>$rmso"); }
html Syntax (Toggle Plain Text)
<p style="text-align:center; margin:2pt 18pt; text-indent:0; background-color: #CC9966; font-size:7.5pt; font-weight:bold; text-decoration:underline"> Sample Company<br> 012 Rhode St.<br> Notown, MI 00000<br> (123)555-7890<br> Fax: (123)555-7891<br> <?php local_emlink("info", "header", "sample.com", "Contact"); ?> </p>
html Syntax (Toggle Plain Text)
<a class="header" href="about:" onclick='local_emclick("info", "sample.com"); return false;'>Contact</a>
Last edited by Fest3er : Jan 2nd, 2008 at 3:57 pm.
•
•
Join Date: Dec 2007
Location: www.JavaScriptBank.com
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 1
good post, but you should provide demo for these
www.JavaScriptBank.com - 2.000+ free JavaScripts
Start hosting from: $22/year | With promo code: 97USDD | At DreamHost
Start hosting from: $22/year | With promo code: 97USDD | At DreamHost
•
•
Join Date: Aug 2007
Posts: 52
Reputation:
Rep Power: 2
Solved Threads: 2
Quite right. Do note that if you copy/paste the examples below, you may receive an error. Daniweb's VB seems to insert "<b></b>" between 'about' and ':' in the HTML example.
Minimal PHP example:
php Syntax (Toggle Plain Text)
<html><body> <?php function local_emlink($one, $two, $three, $four, $five="") { if ($five!="") { $smso = "<b>"; $rmso = "</b>"; } else { $smso = ""; $rmso = ""; } print("$smso<a class=\"$two\" href=\"about:\" onclick='local_emclick(\"$one\", \"$three\"); return false;'>$four</a>$rmso"); } ?> <script language="javascript"> // Action taken when an email 'link' is clicked function local_emclick(parm1, parm2) { test_4 = "lto:"; d37 = "@"; t2 = "mai"; parm = t2+test_4+parm1+d37+parm2; self.location = parm; } </script> <p style="text-align:center; margin:2pt 18pt; text-indent:0; background-color: #CC9966; font-size:12pt; font-weight:bold; text-decoration:underline"> Example Company<br> 012 Rhode St.<br> Notown, MI 00000<br> (123)555-7890<br> Fax: (123)555-7891<br> <?php local_emlink("info", "header", "example.com", "Contact"); ?> </p> </body></html>
Minimal HTML example (produce by the above PHP):
html Syntax (Toggle Plain Text)
<html><body> <script language="javascript"> // Action taken when an email 'link' is clicked function local_emclick(parm1, parm2) { test_4 = "lto:"; d37 = "@"; t2 = "mai"; parm = t2+test_4+parm1+d37+parm2; self.location = parm; } </script> <p style="text-align:center; margin:2pt 18pt; text-indent:0; background-color: #CC9966; font-size:12pt; font-weight:bold; text-decoration:underline"> Example Company<br> 012 Rhode St.<br> Notown, MI 00000<br> (123)555-7890<br> Fax: (123)555-7891<br> <a class="header" href="about:" onclick='local_emclick("info", "example.com"); return false;'>Contact</a></p> </body></html>
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
advice ajax asp browser cell code css developer development div dreamweaver email encryption eu firefox gmail google google checkout html html api javascript javascript tab menu with rounded corners generator microsoft mobile mozilla msdn news office onecare phishing phones professional security software spam spamming sql stocks symantec tables technology thunderbird virus vista w3c web webmail wysiwyg xml
- Previous Thread: A beginner AJAX tutorial
- Next Thread: Cant get the cell values,please help,thanks.


Hybrid Mode