JavaScript Tag Placement
In
Javascript, SCRIPT tags can be inserted into three places: in between the two
BODY tags, in between the two HEAD tags, and as a link to an external file,
also in the HEAD section.
In
between the two body tag:<! Doctype html>
<Html>
<Head>
<Title>Script in body tag</title>
</head>
<Body>
<script type=”text/javascript”>
alert (“hello every one”);
</script>
</body>
</html>
The reason to do it this way is because the web page itself will have loaded before the script is read. If it's in the HEAD section, the script will be parsed before any HTML or CSS elements are loaded.
No comments:
Post a Comment