How can I include some javascript code in an html block on a page? I tried including it in the text, but the result just displays the code instead of executing it.
My use case is that I want to obfuscate an email address in a mailto link. I tried this:
<script language="JavaScript">
<!-- Begin
user = "PirVilayat";
site = "Inayatiyya.org";
document.write('<a href=\"mailto:' + user + '@' + site + '\">');
document.write(user + '@' + site + '</a>');
// End -->
</script>
That didn’t work; the result just displays the code instead of executing it.
I also tried this:
PirVilayat@Inayatiyya.org
but the display did not change the code @ to an @ sign.
If you’re the only user (or there are only trusted users) then there shouldn’t be any issues. The purifier is only used when editing/saving HTML, it doesn’t have any effect one way or the other outside that.