TinyMCE Editor doesn't allow div or body tags?

TinyMCE Editor doesn't allow div or body tags?

by Elon Zito -
Number of replies: 5

I am trying to build out my front page and I want my users to have Google Charts come up every time they log in so they can see their progress.  However, using the HTML editor, every time I try to use certain tags such as <div> and <body>, when I click "update," it automatically removes them.

I looked into the issue on the Tiny MCE forums and their forums suggested taking a look at the tiny_mce_src.js file.  I thought I needed to edit this code:

// Allow all elements and attributes if verify_html is set to false
if (settings.verify_html === false)
settings.valid_elements = '*[*],';

As I understand it, the '*' implies that all elements should be allowed in the HTML editor.

So what are my options here?  I am able to accomplish my goals with an iframe, but we all know iframes can be insecure and are not very often an ideal solution.  Might I try a piece of code that explicitly allows the <div> and <body> tags?  Should I try a piece of code that bypasses the front page altogether and goes to a custom HTML page that I make?  Should I use a different editor?  Thanks a lot moodlers.

Moodle v2.3

Average of ratings: -
In reply to Elon Zito

Re: TinyMCE Editor doesn't allow div or body tags?

by Christian Herman -

Stripping out the <body> tag makes sense.  A webpage can have only one <body> tag and the front page is obviously already using it.  So the TinyMCE editor and the contents it produces are already inside the <body> area.

I just tested <div> tags in my site and they were retained after updating the HTML editor and even after saving the resource.  How are you using the <div> tag?  If you used them in a <body> tag, the <body> area and all of it's contents would be stripped out.

In reply to Christian Herman

Re: TinyMCE Editor doesn't allow div or body tags?

by Elon Zito -

You were right about the editor accepting the <div> tags.  I guess my issue now is that if I want to go back into the editor after saving some code like this:

<div id="chart_div"></div>
<div id="chart_div1"></div>
<div id="chart_div2"></div>
<div id="chart_div3"></div>

...the editor is completely blank when I go back into it, even though code is definitely there (I know this both because the code briefly flashes on the screen before the editor has a chance to load, and because the charts are rendering properly.

In reply to Elon Zito

Re: TinyMCE Editor doesn't allow div or body tags?

by Elon Zito -

now i'm putting this in

<div id="chart_div"></div>
<div id="chart_div1"></div>
<div id="chart_div2"></div>
<div id="chart_div3"></div>
<div id="chart_div4"></div>

and when i go back in to edit it, it looks like this

<div id="chart_div"></div>
<div id="chart_div1"></div>
<div id="chart_div2"></div>

 

weird

In reply to Elon Zito

Re: TinyMCE Editor doesn't allow div or body tags?

by Christian Herman -

I've experienced similar weird with the HTML editor.  I've taken to storing backups of the HTML for the complex Cloze questions I write.

In reply to Christian Herman

Re: TinyMCE Editor doesn't allow div or body tags?

by Elon Zito -

Yeah that's what I've been doing today.  I guess that will just have to do for now... considering once the front page is done, I won't have to edit it much I think I'll be all right.  Thanks guys!