javascript - Getting "Uncaught SyntaxError: Unexpected token ;" error while using for loop -
here have loop iterator on html elements in jsf application.
var tmp = document.getelementsbytagname("input"); var counter = 0; var arr = new array(); (var = 0; i<tmp.length; i++) { if (tmp[i].parentnode.nodename === "td" && tmp[i].getattribute("type") !== "submit") { arr[counter] = tmp[i]; counter++; } } this loop inside script tag:
<script type="text/javascript"> <!-- //--> </script> when load page in web browser following error(shown in google chrome developer tools)

as can see in screenshot, script in html page has < should have <. syntax error. generating page templating language "escapes" html code? cause problem.
one solution put javascript code in separate .js file. should avoid escaping , leave code unchanged.
if need have inline javascript right there in html page, templating languages have way turn off escaping specific piece of text.
Comments
Post a Comment