帳號登錄
帳號:
密碼:
記住我 | 忘記密碼 | 帳號註冊
網站導覽
XOOPS : 在PHP中寫JS的方法:使用xos_opal_Theme
作者 su 於 2017年11月10日 11:09:42 (7775 次閱讀)

在class/theme.php中的class xos_opal_Theme
其中有function addScript
我們可以在module的php檔案中使用這個function來新增js

測試用法:
$themeTest = new xos_opal_Theme();

$js =<<< eof
console.log('Hi, friends.');
eof;

$themeTest->addScript(null,null,$js,null);
$themeTest->renderMetas('script',false);

-------------
可以輸出php變數的值

範例:
$result = "我是PHP字串";

$themeTest = new xos_opal_Theme();

$js =<<< eof
console.log("$result");
eof;

$themeTest->addScript(null,null,$js,null);
$themeTest->renderMetas('script',false);


可列印模式 轉寄給朋友

The XOOPS organisation ("XOOPS") is committed to protecting the privacy of users of the XOOPS.org sites.
The website used Ver.2.4.5 POWERED BY XOOPS PROJECT.