从加载中排除外部JavaScript文件

时间:2013-07-05 07:03:51

标签: php javascript

我有问题。在layout.phtml中,我加载了除少数几个页面外我需要的javascript文件:

  

$ this-> headScript() - > prependFile($ this-> basePath(' js.js'),' text / javascript');

     

echo $ this-> headScript()

如何在使用layout.phtml的index.phtml文件中排除此javascript?

1 个答案:

答案 0 :(得分:0)

你可以这样做:

if (__FILE__ != $YOUR_PATH_NAME) {
  $this->headScript()->prependFile($this->basePath('js.js'), 'text/javascript');
  echo $this->headScript()
}

$YOUR_PATH_NAME替换为实际路径。如果块不在索引页上

,则此脚本应在块内执行