0

Trying to put the following in my JSF xhtml template

<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

</script>

I substituted the && with &amp&amp and &ux0026&ux0026 but they don't seem to work

The error I get is: Error Parsing /templates/template.xhtml: Error Traced[line: 8] Element type "a.length" must be followed by either attribute specifications, ">" or "/>".

Does anyone if any suggestions/ideas how to get around this?

Matt Handy
  • 29,855
  • 2
  • 89
  • 112
thejimhale
  • 1
  • 1
  • 1
  • For some reason it took out the code: trying again – thejimhale Apr 25 '11 at 19:46
  • Researched this some more and found that CDATA fixes the problem e.g. – thejimhale Apr 25 '11 at 20:34
  • Solved it this way e.g. //<![CDATA[ function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i – thejimhale Apr 26 '11 at 15:56

1 Answers1

1

The problem is with < in i<a.length, you should escape it too (&lt;), or use CDATA as you said.

Also see this related question: javascript in jsf/icefaces

Community
  • 1
  • 1
Adam
  • 5,045
  • 1
  • 25
  • 31