typo3:在“ includejs”中包含“ headerdata”的“ headerdata”中包含一个JavaScript加载

StackOverflow https://stackoverflow.com/questions/3551767

  •  30-09-2019
  •  | 
  •  

我正在将jQuery加载到我的typo3页面中:

page.headerData.10.value = <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

我包括这样的JavaScript:

page.includeJS {
  file20 = fileadmin/templates/myjq.js
} 

要点是,我需要首先加载jQuery。但是typo3在我的脚本之后将其放置。我该如何交换?

谢谢

有帮助吗?

解决方案

您不想以这种方式包括jQuery;采用

page.includeJSlibs.jquery.external = 1
page.includeJSlibs.jquery = //ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

反而。

http://typo3.org/documentation/document-library/core-documentation/doc_core_tsref/4.3.2/view/1/6/

编辑使用没有特定协议的URL(HTTP或HTTPS)确保包含在SSL和非SSL点上都起作用。

其他提示

Patrick Schriner的小附加组件一口气将所有JS文件包括在内。它还将确保首先加载所选的文件。

您可以添加一条线(forontop),以迫使您的jQuery被包含在顶部。否则,JavaScript似乎更常见于最后一个以加快页面负载的速度。在此示例中,我包括几个文件。特定于jQuery的是jQuery [forceontop] ...好吧,我想SELV解释了。

includeJS {
   1 = fileadmin/templates/website/scripts/javascript.js
   2 = EXT:ogelementslide/res/jquery.easing.1.3.js
   3 = EXT:ogelementslide/res/jquery.easing.compatibility.js
   4 = EXT:ogelementslide/res/jquery.bxSlider.min.js
   jquery = http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js
   jquery.external = 1
   jquery.forceOnTop = 1
}

请注意,数字1-4和jQuery是等效的。我本可以写5而不是jQuery。在这种情况下,本来是:

includeJS {
   1 = fileadmin/templates/website/scripts/javascript.js
   2 = EXT:ogelementslide/res/jquery.easing.1.3.js
   3 = EXT:ogelementslide/res/jquery.easing.compatibility.js
   4 = EXT:ogelementslide/res/jquery.bxSlider.min.js
   5 = http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js
   5.external = 1
   5.forceOnTop = 1
}

br。安德斯

page.headerData.10 = TEXT    
page.headerData.10.value (
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
     <script type="text/javascript" src="fileadmin/templates/myjq.js"></script>
    )

是的,您需要在这里圆括号:)而不是文本,也可以使用HTML。

编辑:您也可以这样做

page.headerData.10.value = <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
page.headerData.20.value = <script type="text/javascript" src="fileadmin/templates/myjq.js"></script>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top