Reputation: 567
Using a Custom HTML module and have the following code:
<h2><a href="mailto:[email protected]" target="_blank">[email protected]</a></h2>
However after saving the module, the rendered code becomes:
<h2>
<script type="text/javascript">
<!--
var prefix = 'ma' + 'il' + 'to';
var path = 'hr' + 'ef' + '=';
var addy61999 = 'info' + '@';
addy61999 = addy61999 + 'studev' + '.' + 'net';
var addy_text61999 = 'info' + '@' + 'studev' + '.' + 'net';
document.write('<a ' + path + '\'' + prefix + ':' + addy61999 + '\'>');
document.write(addy_text61999);
document.write('<\/a>');
//-->\n </script><a href="mailto:[email protected]" style="">[email protected]</a><script type="text/javascript">
<!--
document.write('<span style=\'display: none;\'>');
//-->
</script><span style="display: none;">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></span></h2>
Does anyone know why this is happening?
Upvotes: 1
Views: 1827
Reputation: 567
For anyone else trying to add attributes to anchors that are filtered by the Email Cloaking plugin, you can use this piece of jQuery to add your own attributes after the page has loaded:
HTML Example:
<h2 id="contactUsEmail"><a href="mailto:[email protected]" target="_blank">[email protected]</a></h2>
You cannot put the ID in the anchor tag as the plugin removes this as it renders the page, so use the parent tags and then use ">" to identify a child element, in this case an anchor tag, as so:
jQuery(document).ready(function(){
$("#contactUsEmail > a").attr("target","_blank");
});
This target="_blank" to the anchor link, after the page has loaded, but keeping the Email Cloaking plugin still enabled
Upvotes: 0
Reputation: 386
It is 'Content - Email Cloaking' plugin for protection email in joomla. This plugin changes each email in such way (with js). If you want, you can disable this plugin. But If you found such code with js in source of page it is normal. /libraries/joomla/html/html/email.php - rule for 'email cloaking'
Upvotes: 2