Email Protector Examples

Tip 1: See the browser console for the encoded values of email addresses.
Tip 2: Use the code inspector to see results in HTML (before and after clicking a link).

Simple in-place output

The email address inserted using the append() method:

EmailProtector.append('email-protector', '[email protected]');

The email address inserted using the write() method:

EmailProtector.write('[email protected]');

You can also specify an .

EmailProtector.append('email-link-label', '[email protected]', { linkLabel: 'email link label' });

The second email address decoded with the code 15:

EmailProtector.write('[email protected]', { code: 15 }); // decoding with 15, because it was encoded with 11

The third email address decoded with the code 5 (26 - 47 % 26 = 5):

EmailProtector.write('[email protected]', { code: 5 }); // decoding with 5, because it was encoded with 47

Using global parameters and configuration

The email address with parameters configured using setGlobalParams() and setGlobalConfig():

EmailProtector.setGlobalParams({ email: '[email protected]', subject: 'Message from www' });
EmailProtector.setGlobalConfig({ code: 15, hiddenSpan: false, htmlComments: false });
...
EmailProtector.write();

Some different email address after using resetParams() and resetConfig():

EmailProtector.resetParams();
EmailProtector.resetConfig();
...
EmailProtector.write('[email protected]');

But using now the write() method without the email parameter (after resetting globals) will give an error:

EmailProtector.write();

Uncaught TypeError: EmailProtector: undefined is not a valid email address