473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Email hiding JavaScript not working :(

I put this together from some other scripts I am using on a site. I'm
trying to make a better email hiding script. It isn't working. Also, it
causes Internet Explorer 6 SP2 to block the script as "active content". :(

The idea is that if the user doesn't have JavaScript enabled, they will see
an image of the email address (that can't be read by email harvesting
programs). If JavaScript is enabled, the image will be hidden and the
javascript will generate the email address in an "mailto:" link text.

<script language=javascript>
<!--
var name = "contact"
var domain = "mysite.com"
document.write("Email: " + name + "@" + domain) // this is going to be
changed to a href=mailto: link...

// hides email image below if JavaScript is enabled
var obj;
obj = document.getElementById("email");
obj.style.display = "none";
//-->
</script>

<div id="email" style="display: inline;">
<img src="images/email.gif" alt="Email address" />
</div>
Aug 16 '05 #1
4 5161
web_design wrote:
I put this together from some other scripts I am using on a site. I'm
trying to make a better email hiding script. It isn't working. Also, it
causes Internet Explorer 6 SP2 to block the script as "active content". :(
There is little point in 'hiding' email addresses in web pages. Do a
search on "hide email address" and you will find many threads discussing
it. Here's one that's only a couple of weeks old:

<URL:http://groups-beta.google.com/group/news.admin.net-abuse.email/browse_frm/thread/52b865188d082c35/22ae192f3ff1a9ef?q=hide+email+address&rnum=4&hl=en #22ae192f3ff1a9ef>

It is generally accepted that a form is better than depending on the
user having an email client configured to respond to 'mailto:'.

The idea is that if the user doesn't have JavaScript enabled, they will see
an image of the email address (that can't be read by email harvesting
programs). If JavaScript is enabled, the image will be hidden and the
javascript will generate the email address in an "mailto:" link text.

<script language=javascript>
Language is depreciated, type is required:

<script type="text/javascript">
<!--
HTML comments inside script tags are completely unnecessary and possibly
harmful. Don't use them.
var name = "contact"
var domain = "mysite.com"
document.write("Email: " + name + "@" + domain) // this is going to be
changed to a href=mailto: link...
Sufficient obfuscation may be:

document.write("Email: " + name + "@" + domain);

// hides email image below if JavaScript is enabled
var obj;
obj = document.getElementById("email");
obj.style.display = "none";
Or:

if ( document.getElementById ) {
var obj = document.getElementById("email");
}
if ( obj && obj.style ) {
obj.style.display = "none";
}

But it will still fail because the element with id 'email' doesn't exist
yet. Put the script below the element and you'll have a better chance
of success. Also, the image should only be hidden if the entire script
works (see below).
//-->
</script>

<div id="email" style="display: inline;">
<img src="images/email.gif" alt="Email address" />
Is this really XHTML? If not, use the HTML markup declaration close
delimiter (">") without a slash.
</div>

<script type="text/javascript">

if ( document.getElementById ) {
var obj = document.getElementById("email");
}
if ( obj && obj.style ) {
obj.style.display = "none";

// Replace with chosen obfuscation or whatever...
var name = "contact"
var domain = "mysite.com"
document.write("Email: " + name + "@" + domain)

}

</script>


--
Rob
Aug 16 '05 #2
JRS: In article <in**************@news.optus.net.au>, dated Tue, 16 Aug
2005 03:49:34, seen in news:comp.lang.javascript, RobG
<rg***@iinet.net.auau> posted :

There is little point in 'hiding' email addresses in web pages. Do a
search on "hide email address" and you will find many threads discussing
it. Here's one that's only a couple of weeks old:

<URL:http://groups-beta.google.com/group/...l/browse_frm/t
hread/52b865188d082c35/22ae192f3ff1a9ef?q=hide+email+address&rnum=4&hl=en #22ae19
2f3ff1a9ef>

It is generally accepted that a form is better than depending on the
user having an email client configured to respond to 'mailto:'.


It is not universally accepted (even disregarding those who provide
<TEXTAREA ROWS="3" WRAP="VIRTUAL" COLS="11"></TEXTAREA> to write in)
that only forms should be used, though.

Those who read Web pages off-line may find forms less convenient.

Those who like to keep records of E-mail will like to keep the
initiating message in the same form.

ISTM that the best approach (where forms can be used; I don't want to
provide such on my site) is to give the user a choice - provide a form
and also an E-mail address (not necessarily with mailto: or written /en
clair/) and, for businesses, an address for traditional mail too.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 16 '05 #3
"RobG" <rg***@iinet.net.auau> wrote in message
news:in**************@news.optus.net.au...
web_design wrote:
I put this together from some other scripts I am using on a site. I'm
trying to make a better email hiding script. It isn't working. Also, it
causes Internet Explorer 6 SP2 to block the script as "active content".
:(


There is little point in 'hiding' email addresses in web pages. Do a
search on "hide email address" and you will find many threads discussing
it. Here's one that's only a couple of weeks old:

<URL:http://groups-beta.google.com/group/news.admin.net-abuse.email/browse_frm/thread/52b865188d082c35/22ae192f3ff1a9ef?q=hide+email+address&rnum=4&hl=en #22ae192f3ff1a9ef>

It is generally accepted that a form is better than depending on the user
having an email client configured to respond to 'mailto:'.


Thanks for your JavaScript advice--I will put it to use.

I want to put the email address on the web site because I prefer it when I
can go to a web site and get an email address. Especially for
business-to-business correspondance. I also have a form on the site, but I
want to keep everyone happy. Also in this case it is for sending
attachments and I'd rather do it this way than write an upload form in PHP.
Aug 16 '05 #4

"Dr John Stockton" <jr*@merlyn.demon.co.uk> wrote in message
news:I8**************@merlyn.demon.co.uk...
JRS: In article <in**************@news.optus.net.au>, dated Tue, 16 Aug
2005 03:49:34, seen in news:comp.lang.javascript, RobG
<rg***@iinet.net.auau> posted :

There is little point in 'hiding' email addresses in web pages. Do a
search on "hide email address" and you will find many threads discussing
it. Here's one that's only a couple of weeks old:

<URL:http://groups-beta.google.com/group/...l/browse_frm/t
hread/52b865188d082c35/22ae192f3ff1a9ef?q=hide+email+address&rnum=4&hl=en #22ae19
2f3ff1a9ef>

It is generally accepted that a form is better than depending on the
user having an email client configured to respond to 'mailto:'.


It is not universally accepted (even disregarding those who provide
<TEXTAREA ROWS="3" WRAP="VIRTUAL" COLS="11"></TEXTAREA> to write in)
that only forms should be used, though.

Those who read Web pages off-line may find forms less convenient.

Those who like to keep records of E-mail will like to keep the
initiating message in the same form.

ISTM that the best approach (where forms can be used; I don't want to
provide such on my site) is to give the user a choice - provide a form
and also an E-mail address (not necessarily with mailto: or written /en
clair/) and, for businesses, an address for traditional mail too.


mailto links can be annoying (for example, when at an Internet cafe and it
suddenly opens up an unconfigured Outlook Express)... but it's very
convienient on my own computer. Also, if you use Firefox you can
right-click on a mailto link and the first item on the context menu is "copy
email address". Very handy.
Aug 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Nel | last post by:
Before I try and reinvent the wheel, can anyone help me with a basic routine to hide email addresses from harvesting. I currently use pull my page content from a db and run this ereg_replace:...
2
by: Jim | last post by:
I have contact info including email address in MySQL. If I use php to extract them into online directory, can a spambot harvest the address? or does the spambot read the raw php code? I...
8
by: TravelMan | last post by:
I'm trying to do a show/hide of several elements on a page and can't get it working in Netscape 4.x. All other Windows browsers are working. My elements all have the same class name. <div...
8
by: pcchong | last post by:
what is the simplest way to put the email address on the homepage so that it is not readable by email extractor or search engine? I remember someone wrote a simple script to do that, but I can't...
2
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups...
17
by: HornyLaBelle | last post by:
I'm hiding the email address on a website with this javascript which works fine: --------------------------------- <p>Send your comments and questions to our <script language=javascript> ...
2
by: Gernot Frisch | last post by:
Hi, is this code: <script type="text/javascript"> var a,b,c,d; a = "x"; c = "kungfu"; b = "y"; d = "com";
24
by: Kourosh | last post by:
I have a lot of DIV tags on an HTML page. I want to group some of them so that I can hide them all together at once if needed. What's a good way to do this? I want this to be compatible with at...
12
by: Ste | last post by:
Hi there, I've got a website with a list of Frequently Asked Questions, so there's a question and answer in a long list down the page. Can anyone recommend a simple script that would allow me...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.