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 "";

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)?

Dani AI

Generated

The behavior shown in this thread is Joomla's built‑in email cloaking: the CMS replaces visible addresses with a small JavaScript snippet that assembles a mailto link client‑side to frustrate scrapers. correctly guessed a cloaking routine and confirmed that disabling the cloaking plugin removed the injected script. The core plugin can also be set to output non‑clickable text instead of links. (docs.joomla.org)

Where that control lives: open the Administrator, go to Extensions → Plugins (filter or search for "email" or "content"), find the "Content - Email Cloaking" plugin and either unpublish it or change its Mode to "Non‑linkable text". For single articles the cloaking can be turned off inline with the article override. Developers can also call Joomla's cloaking routine from code and request non‑linkable output, for example with the JHtml email cloak call. Example usage:

echo JHtml::_('email.cloak', 'user@example.com', 0);

(0 sets non‑linkable text). (docs.joomla.org)

If a third‑party component (forms, modules) shows the script instead of the final address, the usual fixes are: change the plugin ordering so the content plugin runs after the extension, disable the cloaking plugin for that area, or re‑save affected content so the plugin reprocesses it. Some extensions (e.g., Regular Labs Email Protector) offer more flexible site‑wide protection and different display options. Consider using a contact form or rendering an address as an image if spam risk is a concern. (rsjoomla.com)

Summary: the JavaScript you saw was intentional cloaking. Disabling or adjusting the "Content - Email Cloaking" plugin, using per‑article overrides, or using the JHtml cloak call gives you control over whether addresses appear as plain text or as mailto links. (docs.joomla.org)

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 "" 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 "" 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.