貼文的作者是 Joseph Rézeau

Moodle in English -> General help -> inserting javascript -> Re: inserting javascript

Joseph Rézeau發表於
Core developers的相片 Plugin developers的相片 Testers的相片 Translators的相片

Hi Rod,

Your combination of HTML + JS works fine on my Moodle 1.8 installation. Here's what I did.

  1. Upload testpage.htm and test.js to my course files.
  2. In a Moodle course, Add a Resource, select Link to a file or Web site
  3. Name the resource Rod Ward
  4. Select testpage.htm
  5. Select Keep page navigation visible on the same page
  6. see result attached: Hello world! is displayed, the call to the js file works

Please note that there is no need to check the Enable trusted content box as advised by John. Uploaded HTML files are quite free to call JavaScript routines, either located within the HTML file itself or in external files (as in your example).

Are you quite sure that your htm and js files are in the same course directory? i.e. that there is no path problem?

What exactly happens when you try to view your testpage.htm as a course resource? Nothing? Now, if you upload both your files to your course files and go there, what happens if you click on the testpage.htm? you should see the Hello world! message displayed. If not, then there must be something wrong with your moodle installation somewhere.

Joseph

附件 image00.jpg
Core developers的相片 Plugin developers的相片 Testers的相片 Translators的相片
Tony > Can it be made to jump back to the correct place after a submission, with >1Q per page?

This request has been partly answered in this post. Unfortunately, this (desirable) behavior has not yet been implemented in current Moodle versions.

Joseph