Search This Blog

Sunday, February 12, 2012

Adding Javascript to "page" resource

Well this has been bugging me for a while - every time I tried to insert Javascript into the moodle html editor it never worked. You could embed content with <object> or <iframe> tags....but I'm against that because of display issues on different browsers.

Well I've finally found the simple solution - you need an extra identifier in your javascript.


<script type="text/javascript" language="javascript">
//<![CDATA[
               your code here....
               //]]>
</script>

All you need to do is add the code marked in yellow above, purge your moodle cache and voila! Your javascript now works inside the moodle html editor!

Important Note:  You need to try this using "standard web forms". This option can be changed from your profile settings.

2 comments:

  1. Thank you... I've been looking for this for a while. It works, and it solves a lot of problems.

    ReplyDelete
  2. Exactly what i was looking for...
    Thank you very much!

    ReplyDelete