[TYPO3-english] including javascript code in template

Patrick Broens patrick.broens at typo3.org
Tue May 7 10:14:39 CEST 2013


Hi Francesc,

When looking at the javascript you don't need to have Javascript at all,
but can handle this by CSS. Do you really need the class name? Can't you
do something like

#nav li:hover {
	// Do something here
}

Just my two cents

Patrick



On 7-5-13 9:30 , Francesc Juliana wrote:
> hello everybody:
> I am trying to include javascript code in head of every page in order to get 
> top menu working.
> I use the following code in template but the code is not included in result 
> pages.
> Anyone knows what I am doing wrong?
> Thanks in advance.
> 
> Francesc
> 
>  page.headerData.10.value (
>   <script type="text/javascript"><!--//--><![CDATA[//><!--
> 
>  sfHover = function() {
>   var sfEls = document.getElementById("nav").getElementsByTagName("LI");
>   for (var i=0; i<sfEls.length; i++) {
>    sfEls[i].onmouseover=function() {
>     this.className+=" sfhover";
>    }
>    sfEls[i].onmouseout=function() {
>     this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
>    }
>   }
>  }
>  if (window.attachEvent) window.attachEvent("onload", sfHover);
>  //--><!]]></script>
>  ) 
> 
> 


-- 
Patrick Broens
TYPO3 Core Team member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-english mailing list