Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8591865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:37:10+00:00 2026-06-11T23:37:10+00:00

I have the html below; in Joomla email addresses appear on your website obfuscated,

  • 0

I have the html below; in Joomla email addresses appear on your website obfuscated, or ‘cloaked’. I have been using this to display email addresses on my website, JHtml::_(’email.cloak’, ‘demo@example.com’). But I can’t seem to display an email address in an input text field.

<input id="email_field" name="email" placeholder="<?php echo JHtml::_('email.cloak',$result->email_address, 0); ?>" type="text" />

Using the code above will generate the following script in the input field..

<script type='text/javascript'>  
    <!--  var prefix = 'ma' + 'il' + 'to';  
    var path = 'hr' + 'ef' + '=';  
    var addy16915 = 'user' + '@'; 
    addy16915 = addy16915 + 'user' + '.' + 'com';  
    document.write(addy16915);  //-->\n 
</script>

<script type='text/javascript'>  
    <!--  document.write('<span style=\'display: none;\'>');  //-->  
</script>

This email address is being protected from spambots. You need JavaScript enabled to view it.

<script type='text/javascript'>  
    <!--  document.write('</');  document.write('span>');  //-->  
</script>

Any ideas? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:37:11+00:00Added an answer on June 11, 2026 at 11:37 pm

    JHtmlEmail::cloak can only write document text, it can not write in element attributes as in your case. If you really need this you would have to create your own JHtml helper. This could be accomplished by the steps below.

    Implementing a Joomla function for cloaking emails in attributes:

    Create the helper class at your_components/helpers/html/specialemail.php:

    <?php
    defined('_JEXEC') or die;
    
    abstract class JHtmlSpecialEmail
    {
        public static function cloak($id, $attribute, $mail)
        {
            // convert text
            $mail           = JHtmlSpecialEmail::_convertEncoding($mail);
            // split email by @ symbol
            $mail           = explode('@', $mail);
            $mail_parts     = explode('.', $mail[1]);
            // random number
            $rand           = rand(1, 100000);
    
            $replacement    = "\n <script type='text/javascript'>";
            $replacement    .= "\n <!--";
            $replacement    .= "\n var prefix = '&#109;a' + 'i&#108;' + '&#116;o';";
            $replacement    .= "\n var path = 'hr' + 'ef' + '=';";
            $replacement    .= "\n var addy". $rand ." = '". @$mail[0] ."' + '&#64;';";
            $replacement    .= "\n addy". $rand ." = addy". $rand ." + '". implode("' + '&#46;' + '", $mail_parts) ."';";
            $replacement    .= "\n document.getElementById('$id').$attribute = addy$rand.replace(/&#(\d+);/g, function (m, n) { return String.fromCharCode(n); });";
            $replacement    .= "\n //-->";
            $replacement    .= '\n </script>';
    
            return $replacement;
        }
    
        protected static function _convertEncoding($text)
        {
            // replace vowels with character encoding
            $text   = str_replace('a', '&#97;', $text);
            $text   = str_replace('e', '&#101;', $text);
            $text   = str_replace('i', '&#105;', $text);
            $text   = str_replace('o', '&#111;', $text);
            $text   = str_replace('u', '&#117;', $text);
    
            return $text;
        }
    }
    

    Then write your input email element like:

    <input id="email_field" name="email" placeholder="" type="text" />
    <?php JHTML::addIncludePath(JPATH_COMPONENT.DS.'helpers'.DS.'html'); ?>
    <?php echo JHtml::_('specialemail.cloak', 'email_field', 'placeholder', 'email@domain.com'); ?>
    

    It uses the same cloak algorithm as the original Joomla cloak function. Instead of using document.write to output the email to the document, it uses a snippet from this answer to decode the ASCII entities and then sets the value to the chosen attribute directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have the HTML below: <div style=display:none;> <span id=hello>Hey</span> </div> And I do
I am using jQuery UI 's tab view. I have included my HTML below,
I have html and css as below - .title { display: block; background-color: red;
In the below shown html i have this main div as cxfeeditem feeditem and
I have a html like below wherein there are multiple forms. I generate this
I am using JQuery and I have below HTML with checkboxes in it. <div
I am using JQuery and I have below HTML with checkboxes in it. I
I have the HTML given below: <ul id=thumbsPhotos> <li src=/images/1alvaston-hall-relaxing-lg.jpg onclick=updatePhoto (this.title)><img src=/images/1alvaston-hall-relaxing-sl.jpg width=56
I have this the html below and in my CSS I write .CommentSection :nth-child(5n)
I have dropdown using CSS and HTML below: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.