Can JavaScript be used in HTML Editor

Can JavaScript be used in HTML Editor

by Allen Moore -
Number of replies: 2
I'm trying to setup a topic block on my frontpage to include text that would change every day through the use of a javascript section. When I put it in the first time...it took out all the line breaks (making it nearly impossible to debug later) and, instead of just displaying the text, it put the result of the script inline as html. When I tried to start over and did it again, it didn't display the javascript output at all. Can Javascript be used in the HTML editor? Is it possible to keep the HTML editor from taking out all of the line breaks in the code so that it can be re-visited easier?

Thanks.
Average of ratings: -
In reply to Allen Moore

Re: Can JavaScript be used in HTML Editor

by Itamar Tzadok -
Yes but only in text mode (text mode). If you want the javascript to reside in the block you will need to disable the HTML Editor in your profile so that section editing will use only standard web forms, or else the editor will mess up your code as soon as you open the block for editing. Alternatively you can put the javascript in a js file and only refer to it from the block which will minimize the code in the block and allow you to modify the code outside the block and without disabling the Editor.

Hope that helps. smile
In reply to Allen Moore

Re: Can JavaScript be used in HTML Editor

by James Snell -

Yeah, I'd like this too.. I'm sure the HTML editor nukes Javascript input as a security measure. However this is also inspiring me to find ugly solutions that I can just see leading to pain later. What would work best for me is a WYSIWYG that will allow javascript editing for certain users and notifies others if they're editing a page without javascript editing permission (and thus will cause the javascript to be disabled upon saving their edits).

But for now, I'll do the hacky thing..

Average of ratings: Useful (1)