HTML5 Javascript SWITCH not running in head or body -
i have simple code written in js , embedded in html5 document. cannot thing run no matter place script part (head or body). have enabled content in browsers none of them runs script.
any ideas issue be?
<!doctype html> <html> <title>tryme</title> <head> </head> <body> <script> var instr = prompt("which instrument play?"); switch(instr) { case "violin": case "piano": alert("me too!"); break; case "drums": case "ukulele": alert("sonds good"); break; case "whistle": alert("omg!!!"); break; default: alert("whatever..."); } </script> <noscript>"your browser doesnt support javascript"</noscript> </body> </html>
your semi-colon looking characters (;
) showing unicode:
u+037e : greek question mark
rather correct semi-colons (;
):
u+003b : semicolon
with "wrong semi-colon", see error in browser developer console (usually press f12 open):
uncaught syntaxerror: unexpected token illegal
javascript supports unicode directly in source files, have careful characters used in source.
Comments
Post a Comment