0

I am new to moodle. I have a requirement to run a js every time a user clicks on a download file or watch a video. I don't know where or how to add these files.

I have seen how $page is used.

But is there a global location, like the, master page in .net?

Buzzzzzzz
  • 1,074
  • 13
  • 17
  • 4
    Possible duplicate of [How to include external JavaScript on my Moodle page?](https://stackoverflow.com/questions/25219176/how-to-include-external-javascript-on-my-moodle-page) – Mosquito Feb 15 '19 at 10:26
  • Its a bit different, I want a global page load. – Buzzzzzzz Feb 15 '19 at 10:57

1 Answers1

2

You can create a new js file in your Moodle theme folder.

Path to create new js file

theme->your_theme_folder->javascript-> create new js file here.

Now include your js file in your_theme_folder->config.php like below code

$THEME->javascripts_footer = array('modernizr');

Then you have to purge all cache in Moodle by going to

Site Administration->Development->Purge all caches

That's it your js code will work on all page

Sonil Gandhi
  • 179
  • 11