Search code examples
javascriptdotnetnuke-moduledotnetnuke-5

Why is document.write no longer working for me?


I'm working in DotNetNuke but this doesn't really seem to be strictly a DNN problem.

I am using a DNN provided method in my module called FormatEmail which uses document.write to write out an email like like so:

<script language="text/javascript">

<!--
  document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,119,101,98,109,105,110,64,97,116,101,110,118,101,108,100,116,46,111,114,103,34,62,119,101,98,109,105,110,64,97,116,101,110,118,101,108,100,116,46,111,114,103,60,47,97,62))
// -->

</script>

I just installed DNN 5 which I know includes jQuery among other additions to the codebase. Will jQuery stop the document.write code from working?

Should DNN be using another method to cloak text from bots?

Should I stop using this method as a way of cloaking my email addresses?

Update: The page is not using xhtml.


Solution

  • I think I found the specific answer in the DNN bug tracker:

    the output should be:

    <script type="text/javascript">
    
    //<![CDATA[
     document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,84,101,115,116,64,106,101,102,102,109,97,114,116,105,110,46,99,111,109,34,62,84,101,115,116,64,106,101,102,102,109,97,114,116,105,110,46,99,111,109,60,47,97,62))
    //]]>
    
    </script>
    

    This seems to fix the issue for my site (which wasn't running XHTML).

    The bug is located here.