JavaScript is client side dynamic pages technology.It is object based scripting language and cross platform.As we know JS is not a compiled language, it is translated language.
Application of JS :
You can use JS for create interactive web pages.It is mainly used for :
- For client side validation.
- For create dynamic drop down.
- For displaying Date and Time
Example of JavaScript :
<script type="text/javascript">
document.write("Hello from Tech Talk Tricks");
</script>
Explanation of above example :
<script> : If you want to use java script then use <script> tag in your HTML document.
type="text/javascript : The text/javascript is the content type that provides information to the browser about the data.
document.write() : this function used to print dynamic content through JS.
You can use JavaScript in these places of HTML document :
- Between the body HTML tag
- Between the head HTML tag
- In external .js file.
Javascript code in body tag :
You can use javascript code in body tag of html as follows :
<html>
<body>
<script type="text/javascript">
alert("Hello Tech Talk Tricks");
</script>
</body>
</html>
Javascript code in head tag :
- <html>
- <head>
- <script type="text/javascript">
- function welcome(){
- alert("Hello TechTalkTricks");
- }
- </script>
- </head>
- <body>
- <p>Welcome to Tech Talk Tricks</p>
- <form>
- <input type="button" value="click" onclick="welcome()"/>
- </form>
- </body>
- </html>
No comments:
Post a Comment
Share your views after read this post