JavaScript won't work if placed inside the body of a web page? -
i'm new javascript , i've learned javascript can place between <head></head>
or <body></body>
sections, have been working in project , works fine inside head not body section of page.
examples:
working fine this:
<!doctype html> <html lang="en"> <head> <title>example page</title> <script> function yetanotheralert(texttoalert) { alert(texttoalert); } yetanotheralert("hello world");
and not working way:
<!doctype html> <html lang="en"> <head> <title>example page</title> </head> <body> <script> function yetanotheralert(texttoalert) { alert(texttoalert); } yetanotheralert("hello world"); </script> </body> </html>
your code snippet didn't show closing tag. double check if close script block correctly.
it's better specify type of scripting language too.
<script language='javascript'> .... </script>
Comments
Post a Comment