moodle 1.9.9 HTML editor changes javascript function

moodle 1.9.9 HTML editor changes javascript function

by Erik Dóša -
Number of replies: 1

Hi,

in our course i'm using .swf flash animation. first  .swf is not visible. students have to click a button to see the animation. i'm using this javascript code to toggle between css display: hidden or block properties.

<a onmousedown="if(document.getElementById('show_div').style.display == 'none'){ document.getElementById('show_div').style.display = 'block'; }else{ document.getElementById('show_div').style.display = 'none'; }" href="javascript:;">Shows DIV</a> 
<div style="display:none;" id="show_div">

but when switching from viewsource mode to html, editor changes the code into this not working code

<a href="javascript:;" onmousedown="function onmousedown(event) { if (document.getElementById("show_div").style.display == "none") { document.getElementById("show_div").style.display = "block"; } else { document.getElementById("show_div").style.display = "none"; } }">Shows DIV:</a>
<div id="show_div" style="display: none;">

any suggestions how to avoid this?

thank you

Average of ratings: -