If you want something you've never had, you must be willing to do something you've never done!

Powered by Blogger.

How and Where Do You Place JavaScript Code? 1

Cerita Semalam Aaz | 3:37 PM | ,







How to put a JavaScript code into an HTML page?


•Use the <script> tag (also use the type attribute to define the scripting language)



<html>
<head>
<script type="text/javascript">
...
</script>
</head>
<body>
<script type="text/javascript">
...
</script>
</body>
</html>




Where Do You Place Scripts?


• Scripts can be in the either <head> section or
<body> section

• Convention is to place it in the <head> section




<html>
<head>
<script type="text/javascript">
....
</script>
</head>




Referencing External JavaScript File


• Scripts can be provided locally or remotely accessible JavaScript file using src attribute



<html>
<head>
<script language="JavaScript" type="text/javascript" src="http://somesite/myOwnJavaScript.js">
</script>
<script language="JavaScript" type="text/javascript" src="myOwnSubdirectory/myOwn2ndJavaScript.js">
</script>

1 Responses So Far:

Related Post

 
Back To Top