By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,498 Members | 1,558 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,498 IT Pros & Developers. It's quick & easy.

Hide email address with image as link

P: n/a
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>

<!--

var contact = "Newsletter Editor"

var email = "news"

var emailHost = "netmechanic.com"

document.write("<a href=" + "mail" + "to:" + email + "@" + emailHost+
">" + contact + "</a>" + ".")

//-->

</script>

</p>
---------------------------------
How can I make an image instead of the text as a link to start this
script?

Thanks in advance

Mar 9 '06 #1
Share this Question
Share on Google+
17 Replies


P: n/a
HornyLaBelle said the following on 3/9/2006 6:42 AM:
I'm hiding the email address on a website with this javascript which
works fine:
No, you just think it works fine.
---------------------------------
<p>Send your comments and questions to our

<script language=javascript>
<script type="text/javascript">
<!--
Drop the ill conceived notion of hiding scripts.
var contact = "Newsletter Editor"

var email = "news"

var emailHost = "netmechanic.com"

document.write("<a href=" + "mail" + "to:" + email + "@" + emailHost+
">" + contact + "</a>" + ".")

//-->
Drop the hiding scripts, it isn't needed anymore and can actually do
harm in some circumstances.
</script>

</p>
---------------------------------
How can I make an image instead of the text as a link to start this
script?


Instead of the variable contact, you would write out an img tag.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 9 '06 #2

P: n/a
HornyLaBelle wrote:
I'm hiding the email address on a website with this javascript
Utter nonsense.
which works fine:


No, it does not.
PointedEars
Mar 9 '06 #3

P: n/a
<p>Send your comments and questions to our
<script language=javascript>
<!--
var contact = '<img src="gfx/some_image.png" alt="email me">'
var email = "news"
var emailHost = "netmechanic.com"
document.write("<a href=" + "mail" + "to:" + email + "@" +
emailHost+
">" + contact + "</a>" + ".")
//-->
</script>
</p>



Mar 9 '06 #4

P: n/a
//-->


Drop the hiding scripts, it isn't needed anymore and can actually do
harm in some circumstances.


Why? What's the problem?
Mar 9 '06 #5

P: n/a
> > How can I make an image instead of the text as a link to start this
script?


Instead of the variable contact, you would write out an img tag.


I tried this but it doesn't work. Can you please give an example? I
don't know a lot about javascript...

Mar 9 '06 #6

P: n/a
Gernot Frisch wrote:
//-->


Drop the hiding scripts, it isn't needed anymore and can actually do
harm in some circumstances.

Why? What's the problem?


The main problem is that some script authors think they can use HTML style
comments anywhere in the script, then can't work out why it won't run.

The tags also get carried over to .js files where their potential effects
can be masked further. The content of script elements should be passed
as-is to the script engine. It seems that modern browsers either remove
the tags before passing the content to the script engine, or the engine
itself deals with them. Provided the opening tag comes before any real
script they don't cause a problem, but that can't be relied upon /ad
infinitum/.

Note that comments should never have been required for script elements
inside the head, which is where most of them are.

Another potential hazard is if the tags are used with XHTML - but again
some browsers seem to 'fix' that.

--
Rob
Mar 9 '06 #7

P: n/a

"HornyLaBelle" <sa****@gmx.de> schrieb im Newsbeitrag
news:11**********************@u72g2000cwu.googlegr oups.com...
> How can I make an image instead of the text as a link to start
> this
> script?


Instead of the variable contact, you would write out an img tag.


I tried this but it doesn't work. Can you please give an example? I
don't know a lot about javascript...


See my other reply - it's all there
Mar 9 '06 #8

P: n/a
Greetings,

First I must apologize for users like PointedEars who somehow think
they are making a contribution by bad mouthing people who need help. It
seems every post they make does nothing to further anyone's
knowledge.

Here is how you would fix your code to use an image:

<script language=javascript>
var contact = "Newsletter Editor";
var email = "news";
var emailHost = "netmechanic.com";
document.write("<a href='mailto:"+email+"@"+emailHost+"'><img
src='http://groups.google.com/groups/img/groups_medium.gif' width='150'
height='58' border='0'>"+contact+"</a>");
</script>

Also, if interested I have written a free JavaScript utility I use for
all my clients that encrypts email links for you. You can even pass it
a CSS class to use While the method you are using works for basic
protection, malicious harvesting robots can still read your source code
and piece things together. Especially when you use keywords like
"email".

http://www.manifestinteractive.com/tools/hiddenemail/

Hope this helps,
Peter Schmalfeldt

HornyLaBelle wrote:
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>

<!--

var contact = "Newsletter Editor"

var email = "news"

var emailHost = "netmechanic.com"

document.write("<a href=" + "mail" + "to:" + email + "@" + emailHost+
">" + contact + "</a>" + ".")

//-->

</script>

</p>
---------------------------------
How can I make an image instead of the text as a link to start this
script?

Thanks in advance


Mar 9 '06 #9

P: n/a
Manifest Interactive wrote:
First I must apologize for users like PointedEars who somehow think
they are making a contribution by bad mouthing people who need help.
It seems every post they make does nothing to further anyone's
knowledge.
At least I /know/ what I am talking about.

You are not helping the OP by posting this "solution", you are hurting
him/her in the mid-term. Because e-mail communication will be impossible
for many, if not most, of his/her users while you give the false impression
that this would be a viable approach that serves at least many users.
There is a word for that: incompetence.
Here is how you would fix your code to use an image:

<script language=javascript> ^^^^^^^^^^^^^^^^^^^^ var contact = "Newsletter Editor";
var email = "news";
var emailHost = "netmechanic.com";
document.write("<a href='mailto:"+email+"@"+emailHost+"'><img
src='http://groups.google.com/groups/img/groups_medium.gif' width='150'
height='58' border='0'>"+contact+"</a>"); ^^^^
The markup is not Valid, and therefore not supposed to be interoperable.

1. The `language' attribute is deprecated long since (December 1999),
the `type' attribute is required. The language attribute is not
Valid in HTML 4.01 Strict, XHTML 1.0 Strict, and XHTML 1.1.

2. mailto: is known to be highly unreliable (IOW: known not to work).

3. Writing the link with client-side scripting and so introducing a
dependency on that technique makes it even worse.

4. The `img' element requires the `alt' attribute, as text alternative
if the image cannot be displayed.

5. ETAGO delimiters </ must be escaped within CDATA element content, or
the element is considered to end prematurely by the markup parser,
causing a syntax error for the script engine here.

So there are the following possibilities:

1. There is no client-side script support, the script is filtered by a
proxy, or the client works strictly standard compliant:

The user sees exactly nothing, and depending on the strictness of
the parser, if there is client-side script support, and the script
is not filtered, the user gets a nice error message, too.

2. There is client-side script support, the script is not filtered,
and despite the markup being not Valid the script is executed, but

a) the user is blind or visually impaired, and therefore can not find
the link (there is no text that can be interpreted by a Braille line
or read to him aloud by a screenreader);
b) there is no e-mail client installed;
c) the HTML user agent (UA) does not support mailto: URIs;
d) the e-mail client is not configured with the UA to handle mailto: URIs

Where each of b) to d) is highly likely with users having a Web mail
account.

For the infinitesimal tiny rest of users, this nonsense actually works.
Big time.
[unsolicited advertising]
[top post]


FOAD!
PointedEars
Mar 9 '06 #10

P: n/a
Thomas 'PointedEars' Lahn wrote:
1. There is no client-side script support, the script is filtered by a
proxy, [...]


.... or by a "desktop firewall", or it is rendered not working by that
(such as with Norton InSecurity). And probably I forgot something more.
PointedEars
Mar 10 '06 #11

P: n/a
The "PointedEars" must be your horns. Oh, and by the way, here is a
word you obviously need the definition to, must be the ONLY thing you
don't know, right?

------------------------------------------------------

ad·ver·tise
v. ad·ver·tised, ad·ver·tis·ing, ad·ver·tis·es
v. tr.

To make public announcement of, especially to proclaim the qualities or
advantages of (a product or business) so as to increase sales.

------------------------------------------------------

Me providing a link to a free tool I wrote that has no marketing on it
that can help people better secure their email links is a NICE and
POLITE thing that I do to HELP people. It is certainly not
"unsolicited advertising". They can even take it and use it
themselves if they want. I don't care. (I capitalized the "big
words" you might not understand).

Well, I am off to help other people, I am sure I will see a response
following this outlining many ways that nothing I submit will work.,
just like you do on everyone else's messages. Sure hope you don't
talk to people in person the way you do on here.

Here's a challenge for you. Write one nice response to a user, come
back here and post the link so I can see that you actually helped
someone out. My bet is that I will never see anything.

Later pessimist

PS, your site http://www.pointedears.de/ needs a lot of work bro.

- Peter Schmalfeldt

Thomas 'PointedEars' Lahn wrote:
Manifest Interactive wrote:
First I must apologize for users like PointedEars who somehow think
they are making a contribution by bad mouthing people who need help.
It seems every post they make does nothing to further anyone's
knowledge.


At least I /know/ what I am talking about.

You are not helping the OP by posting this "solution", you are hurting
him/her in the mid-term. Because e-mail communication will be impossible
for many, if not most, of his/her users while you give the false impression
that this would be a viable approach that serves at least many users.
There is a word for that: incompetence.
Here is how you would fix your code to use an image:

<script language=javascript>

^^^^^^^^^^^^^^^^^^^^
var contact = "Newsletter Editor";
var email = "news";
var emailHost = "netmechanic.com";
document.write("<a href='mailto:"+email+"@"+emailHost+"'><img
src='http://groups.google.com/groups/img/groups_medium.gif' width='150'
height='58' border='0'>"+contact+"</a>");

^^^^
The markup is not Valid, and therefore not supposed to be interoperable.

1. The `language' attribute is deprecated long since (December 1999),
the `type' attribute is required. The language attribute is not
Valid in HTML 4.01 Strict, XHTML 1.0 Strict, and XHTML 1.1.

2. mailto: is known to be highly unreliable (IOW: known not to work).

3. Writing the link with client-side scripting and so introducing a
dependency on that technique makes it even worse.

4. The `img' element requires the `alt' attribute, as text alternative
if the image cannot be displayed.

5. ETAGO delimiters </ must be escaped within CDATA element content, or
the element is considered to end prematurely by the markup parser,
causing a syntax error for the script engine here.

So there are the following possibilities:

1. There is no client-side script support, the script is filtered by a
proxy, or the client works strictly standard compliant:

The user sees exactly nothing, and depending on the strictness of
the parser, if there is client-side script support, and the script
is not filtered, the user gets a nice error message, too.

2. There is client-side script support, the script is not filtered,
and despite the markup being not Valid the script is executed, but

a) the user is blind or visually impaired, and therefore can not find
the link (there is no text that can be interpreted by a Braille line
or read to him aloud by a screenreader);
b) there is no e-mail client installed;
c) the HTML user agent (UA) does not support mailto: URIs;
d) the e-mail client is not configured with the UA to handle mailto: URIs

Where each of b) to d) is highly likely with users having a Web mail
account.

For the infinitesimal tiny rest of users, this nonsense actually works.
Big time.
[unsolicited advertising]
[top post]


FOAD!


PointedEars


Mar 10 '06 #12

P: n/a

Manifest Interactive schrieb:
Here is how you would fix your code to use an image:

<script language=javascript>
var contact = "Newsletter Editor";
var email = "news";
var emailHost = "netmechanic.com";
document.write("<a href='mailto:"+email+"@"+emailHost+"'><img
src='http://groups.google.com/groups/img/groups_medium.gif' width='150'
height='58' border='0'>"+contact+"</a>");
</script>


Manifest Interactive, thanks a lot, but when I copy this script into my
html the image is not displayed. It only works with a text link. I
tried it several different ways, really strange...

Mar 10 '06 #13

P: n/a
Greetings,

Are you copying this script inside your body tag? Also, make sure that
you removed all the line breaks that this forum will put in the code.
In all total there should only be 6 lines of code including the <script
language=javascript> and </script> tags. If you have more than that,
then that is the problem.

Here is a link to a sample page I put up on my site for you:

http://www.manifestinteractive.com/u...imagelink.html

Just copy that code if you want. Hope this solves your problem.

- Peter Schmalfeldt

HornyLaBelle wrote:
Manifest Interactive schrieb:
Here is how you would fix your code to use an image:

<script language=javascript>
var contact = "Newsletter Editor";
var email = "news";
var emailHost = "netmechanic.com";
document.write("<a href='mailto:"+email+"@"+emailHost+"'><img
src='http://groups.google.com/groups/img/groups_medium.gif' width='150'
height='58' border='0'>"+contact+"</a>");
</script>


Manifest Interactive, thanks a lot, but when I copy this script into my
html the image is not displayed. It only works with a text link. I
tried it several different ways, really strange...


Mar 10 '06 #14

P: n/a
HornyLaBelle wrote:
Manifest Interactive schrieb:
Here is how you would fix your code to use an image:
[Invalid code]


Manifest Interactive, thanks a lot, but when I copy this script into
my html the image is not displayed. It only works with a text link.
I tried it several different ways, really strange...


Blind leading the blind ... It would be funny if it would not be so sad.

FWIW, you are looking for a (server-side) form mailer, such as
<URL:http://formmailer.com/ (or write your own in any server-side language;
I prefer PHP), not mailto: or client-side scripting, and certainly not the
nonsense provided by the incompetent spammer posing here. This way, your
e-mail address is known only server-side, not to the users (or a potential
spammer). And _all_ of them will be able to send you e-mail anyway. By
using POST requests and server-side sessions, you can successfully prevent
most attempts spamming to the resource the form points to.
HTH & HAND

PointedEars
Mar 10 '06 #15

P: n/a
Thomas 'PointedEars' Lahn said the following on 3/10/2006 10:36 AM:
and certainly not the nonsense provided by the incompetent spammer posing here.


Everything you said was 100% on the mark except the above. Nothing that
he has posted would qualify as "spam" and whether he is "posing" or
"posting" (I assume that to be a typo but it may be intentional) he
still hasn't spammed this group. It goes back to your typical behavior
of name calling when someone disagrees with you.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 10 '06 #16

P: n/a

Manifest Interactive schrieb:
Are you copying this script inside your body tag? Also, make sure that
you removed all the line breaks that this forum will put in the code.
In all total there should only be 6 lines of code including the <script
language=javascript> and </script> tags. If you have more than that,
then that is the problem.


Manifest Interactive, thank you very much. The line breaks were the
problem. Now it works.

Mar 10 '06 #17

P: n/a

Horny LaBelle wrote:
Manifest Interactive schrieb:
Are you copying this script inside your body tag? Also, make sure that
you removed all the line breaks that this forum will put in the code.
In all total there should only be 6 lines of code including the <script
language=javascript> and </script> tags. If you have more than that,
then that is the problem.


Manifest Interactive, thank you very much. The line breaks were the
problem. Now it works.


You are welcome,
- Peter Schmalfeldt

Mar 12 '06 #18

This discussion thread is closed

Replies have been disabled for this discussion.