简体   繁体   English

如何确保在Joomla中最后添加了JavaScript脚本

[英]How to make sure a javascript script is added last in Joomla

Throughout my site, I have multiple modules that use JFactory::getDocument()->addScript to add various bits and pieces of javascript to be run. 在我的整个站点中,我有多个使用JFactory::getDocument()->addScript来添加各种要运行的JavaScript。 I have a problem though, I can't tell what order javascripts are being added into JFactory::getDocument()->_script['text/javascript'] , and I need to make sure one piece of javascript is added last regardless of the order previous pieces of javascript are added. 不过,我有一个问题,我无法确定将javascripts添加到JFactory::getDocument()->_script['text/javascript']顺序,并且我需要确保最后添加一个 javascript顺序添加以前的javascript。

Is there any sure fire way to be absolutely sure it's added last, without adding the other javascript bits to the start of the JFactory::getDocument()->_script['text/javascript'] variable? 有没有什么肯定的方法可以绝对确定最后添加它, 而无需JFactory::getDocument()->_script['text/javascript']变量的开头添加其他javascript位呢?

使用addCustomTag代替

$document->addCustomTag('<script src="SOURCE" type="text/javascript"></script>');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM