我正在编写自定义模块,我需要将javascript添加到我的网站。 此单个页面仅从数据库进行查询(模板不对其进行任何操作)
我试过这个:
define( '_JEXEC', 1 );
// defining the base path.
if (stristr( $_SERVER['SERVER_SOFTWARE'], 'win32' )) {
define( 'JPATH_BASE', realpath(dirname(__FILE__).'\..\..' ));
} else define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));
define( 'DS', DIRECTORY_SEPARATOR );
// including the main joomla files
require_once ( JPATH_BASE.DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE.DS.'includes'.DS.'framework.php' );
// Creating an app instance
$app =& JFactory::getApplication('site');
$app->initialise();
jimport( 'joomla.user.user' );
jimport( 'joomla.user.helper' );
$jinput = JFactory::getApplication()->input;
$document = &JFactory::getDocument();
$document->addScript('modules/mod_csk/js/num.js');
但我的网站没有添加任何javascript。
此外,我尝试了简单的js代码,但它没有渲染:
echo "<td>"?><script type="text/javascript">alert("Hello");<? echo "</td>"
我不知道原因,也许我错过了。 这个简单的页面此时独立于joomla系统(因此无需关闭和设置) 谢谢你的帮助。