javascript - Unexpected Token < ... cant find issue -
i getting "unexpected token <" error following javascript...
<script type="text/javascript"> function toggle_menu(id) { var e = document.getelementbyid(id); if(e.style.display == 'block') e.style.display = 'none'; else e.style.display = 'block'; } </script> the "<" used designate javascript. i've checked stackoverflow, , see posts suggest following ... none address code nor address problem (so no, not duplicate post)
- changing type "text/javascript" "text/html" ... makes script stop working.
- i've seen recommendations add
<script><![cdata[ /* code here */ ]]></script>... cdata info made script stop working again. - i've seen recommendations remove excess ";" ... didn't fix error.
- remove comment tags (um... there none)
- mixing parenthesis (none see)
this simple javascript, , don't see error coming from.
some more clarification.
- the javascript not in own file. @ top of page.
- there no javascript above code (or js files being called before code).
here content of html tag (stack overflow wont let me type in html tag ...
xmlns="http://www.w3.org/1999/xhtml" lang="en-us"below html calling toggle...
<a href="javascript:void(0)" onclick="toggle_menu('popup-1');"> open window </a>
(note: javascript works, want rid of error)
your code valid if it's in html document. if it's in javascript file (eg: file.js) don't need include <script> tag.
the <script> tag used in html documents include javascript code within html.
the leading character of <script> tag (<) confusing javascript parser, , causing error.
Comments
Post a Comment