Whenever I echo or print a string containing an email address to my webpage the HTML code automatically parses the text and shows it as a "mailto" link.

If I use... echo "Hello";

it prints Hello as expected on the webpage.

If I use... echo "hello@whatever.com";

it now appears as a mailto link, and if I look at the HTML code source the email address now contains all of this additional javascript...

<script language='JavaScript' type='text/javascript'> <!-- var prefix = 'ma' + 'il' + 'to'; var path = 'hr' + 'ef' + '='; var addy27400 = 'myemail' + '@'; addy27400 = addy27400 + 'hotmail' + '.' + 'com'; document.write( '<a ' + path + '\'' + prefix + ':' + addy27400 + '\'>' ); document.write( addy27400 ); document.write( '<\/a>' ); //-->\n </script> <script language='JavaScript' type='text/javascript'> <!-- document.write( '<span style=\'display: none;\'>' ); //--> </script>This e-mail address is being protected from spambots. You need JavaScript enabled to view it <script language='JavaScript' type='text/javascript'> <!-- document.write( '</' ); document.write( 'span>' ); //--> </script>

My question is, how can I show email addresses on my webpage in plain text (i.e. not as an email link)?

Recommended Answers

All 10 Replies

Which editor are you using?

change document.write( '<a ' + path + '\'' + prefix + ':' + addy27400 + '\'>' ); document.write( addy27400 ); document.write( '<\/a>' ); to document.write( addy27400); that should do it!

Which editor are you using?

I'm developing a joomla CMS website, so the editor is an inbuilt editor. I don't think the problem is with the editor itself as all PHP code is saved as is. I simply code echo "myemail@whatever.com" and the resulting webpage shows the text as a "mailto" (active) link. All I want is for the email address to show as plain text.

The conversion appears to occur between the PHP code being sent to the server for processing, and the page output itself. But I have no idea where this javascript code comes from.

change

document.write( '<a ' + path + '\'' + prefix + ':' + addy27400 + '\'>' ); document.write( addy27400 ); document.write( '<\/a>' );

to
document.write( addy27400);

that should do it!

Thanks for the code change suggestion, however, I don't code this javascript into my webpage in the first place... that's the problem. I don't know where this javascript script comes from, and I don't want it to be there. I simply code echo "myemail@whatever.com" into my PHP page and then when it outputs to the screen the email address has automatically been converted from plain text to a "mailto" (active) link. I want it to appear simply as plain text.

Did you try with <code></code> or <pre></pre> tags?

the cms appears to have a function built in to obfuscate email addresses, this obfuscation is the javascript shown.
check the settings in the cms for obfuscation and change it from auto to manual, (maybe).
or try emailaddress&#64;domain.com

if dat doesn't work, i can try n fix it for you...

PS i am a pro php programmer :P

the cms appears to have a function built in to obfuscate email addresses, this obfuscation is the javascript shown.
check the settings in the cms for obfuscation and change it from auto to manual, (maybe).
or try emailaddress&#64;domain.com

Exactly!! Thanks for your suggestion. I'm using Joomla cms and I did some research after reading your post and have just discovered that it does indeed use an inbuilt javascript obfuscation, however, I cannot find any setting in the cms for turning it off or on (auto to manual). I'm certain this is the "culprit".

No doubt the obfuscation function is there for good valid reasons, i.e. protection against spam, but I'm only wanting to show the email addresses in user-access webpages, not publicly accessable pages.

I tried the emailaddress&#64;domain.com but still appears as an email link on the webpage.

Does anyone know where this setting could be in joomla?

the cms appears to have a function built in to obfuscate email addresses, this obfuscation is the javascript shown.
check the settings in the cms for obfuscation and change it from auto to manual, (maybe).
or try emailaddress&#64;domain.com

Ok, I found it... in the cms there's an email cloacking plug-in. All I needed to do was disable it. Thanks for pointing me in the right direction, and thanks to everyone for their suggestions and help.

's good when it works

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.