如何将外部JS文件加载到moodle中? [英] how to load external JS file into moodle?
本文介绍了如何将外部JS文件加载到moodle中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将外部JS文件加载到moodle中?使用moodle api,即moodle库..
how to load external JS file into moodle ? using moodle api ,i.e moodle libraries ..
推荐答案
在 Moodle 2.0 中我一直使用 $PAGE->requires->js()
.
In Moodle 2.0 I have always used $PAGE->requires->js()
.
首先,通过执行以下操作使 $PAGE
可用于您的代码:
To start with, make $PAGE
available to your code by doing:
require_once($CFG->libdir . '/pagelib.php');
global $PAGE;
然后在您的代码中:
$PAGE->requires->js( new moodle_url($CFG->wwwroot . '/blocks/your_block/script.js') );
需要在你的路径周围加上moodle_url()
!
It is required to put moodle_url()
around your path!
这篇关于如何将外部JS文件加载到moodle中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文