/    Sign up×
Community /Pin to ProfileBookmark

I have a page with many many emails on it (it’s a staff directory, and each staff name is a link to their email), but I want to protect the emails as best I can from spam-bots. Right now I’m creating a separate item for each email:

document.write (‘<a href=”mailto:’ + ‘name’ + ‘@domain.com”>’)

But there has to be an easier way! Does anyone know a way that would be simpler/take up less space?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@cyber1Sep 01.2005 — 
But there has to be an easier way! Does anyone know a way that would be simpler/take up less space?[/QUOTE]


There is.

Use Perl or PHP and store the emails in a DB.

-Bill
Copy linkTweet thisAlerts:
@hooloovoo24authorSep 01.2005 — Hm...Okay. Or...ASP?
Copy linkTweet thisAlerts:
@cyber1Sep 01.2005 — Sure thing, if know ASP then go with it.

-Bill
Copy linkTweet thisAlerts:
@UltimaterSep 01.2005 — I can tell you one thing for sure, that they wouldn't survive my bookmarklet that I made ages ago?:
<i>
</i>javascript:void(function(){var els=document.getElementsByTagName("A");var e=[];for(var i=0;i&lt;els.length;i++){if(els[i].getAttribute("href").indexOf("mailto:")!=-1)e[e.length]=els[i].getAttribute("href").split(":")[1]}document.write(e.join("&lt;br&gt;"))}())

But if you want only to protect it from spam bots, you probably don't care if people use bookmarklets on it.

[b]edit:[/b]

You'd best change all mailto links into hyperlinks to a PHP file with a parameter "id" followed by a number, basically doing what cyber1 said having all the emails in a database. Then the PHP file would spit-up the email address with that ID. You can even go as far as using sessions.
×

Success!

Help @hooloovoo24 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...