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?

3
  • For some reason it took out the code: trying again <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> Commented Apr 25, 2011 at 19:46
  • Researched this some more and found that CDATA fixes the problem e.g. Commented Apr 25, 2011 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<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } //]]> Commented Apr 26, 2011 at 15:56

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.