javascript problem in global template

hi all

this is the first time i have tried to put javascript calls into our global template and I appear to be having some problems. When previewing the pages the javascript is not activated.

I have followed the markup as suggested in the developer guide (posted below) and wondered if any of you could see anything obviously wrong with this as to why it doesn’t work.

i have 3 calls to external javascript files - these appear not to be being called when the page loads. The next call which contains javascript rx is replacing my greater than sign with > which i dont want to happen.

<script language="javascript" psx-src="$rxs_navbase/js/jquery-1.2.3.js" src="js/jquery-1.2.3.js" type="text/javascript">;</script>
<link type='text/css' psx-href='$rxs_navbase/css/ui.tabs.css' href='css/ui.tabs.css' rel='stylesheet' media='print, projection, screen' />
<script language="javascript" psx-src="$rxs_navbase/js/jquery-1.2.3.pack.js" src="js/jquery-1.2.3.pack.js" type="text/javascript">;</script>
<script language="javascript" psx-src="$rxs_navbase/js/ui.tabs.pack.js" src="js/ui.tabs.pack.js" type="text/javascript">;</script>
<script type="text/javascript" language="javascript">
	/* <![CDATA[ */
  $(function() {
	 $('#Terms \> ul').tabs({ fx: { opacity: 'toggle' } });
  });
		/* ]]> */
</script>
	<script type="text/javascript" language="javascript">
	  function insertParaNumbers () {
		var terms = document.getElementById('Terms');
		var sections = terms.getElementsByTagName('div');
		var headers = terms.getElementsByTagName('h2');
		j = headers.length;
		headerNo = 0;
		for(var i=0;i<j;i++)
			{
				if (sections[i].className != 'CrossRefBox') {
					headerNo = headerNo+1;
					insertH2 = "<span>"+headerNo+"</span>";
					headers[i].innerHTML = insertH2+headers[i].innerHTML;
					var paras = sections[i].getElementsByTagName('p');
					y = paras.length;
					paraNo=0;
					for (var x=0;x<y;x++) {
						if (paras[x].className != 'NoNumber') {
							paraNo = paraNo+1;
							insertPara = "<span>"+headerNo+"."+paraNo+"</span>";
							paras[x].innerHTML = insertPara+paras[x].innerHTML;
						}
					}
				}
			}
		}
	
		window.onload=insertParaNumbers;
	</script>

thanks
michelle

Hi all

further investigation shows that it is the replacement of the greater than/less than symbols with html that is causing my problems.

can anyone tell me how to stop this happening please.

thanks
michelle

You could try escaping the chars?

Hi

that was my first thought - but i just cant work out how to do it. can anybody help please.

thanks
michelle

Is this in a Velocity or XSL template?

If it’s in an XSL template, you may need to enclose your script code in:

<xsl:text disable-output-escaping=“yes”>

</xsl:text>

so your code may end up looking something like:

<script type="text/javascript" language="javascript">
<xsl:text disable-output-escaping="yes">
	/* &lt;![CDATA[ */
  $(function() {
	 $('#Terms \> ul').tabs({ fx: { opacity: 'toggle' } });
  });
		/* ]]&gt; */
</xsl:text>
</script>

Did you try moving the javascript to an external file and have a reference to it in your global template.

Hello

I have a similar problem

the template is a velocity template