javascript tutorials

JavaScript Tutorial

JavaScript Tutorial
JavaScript Tutorial for beginners and professionals is a solution of client side dynamic pages.
JavaScript is an object-based scripting language that is lightweight and cross-platform.
JavaScript is not compiled but translated. The JavaScript Translator (embedded in browser) is responsible to translate the JavaScript code.

Where JavaScript is used

JavaScript is used to create interactive websites. It is mainly used for:
  • Client-side validation
  • Dynamic drop-down menus
  • Displaying data and time
  • Displaying popup windows and dialog boxes (like alert dialog box, confirm dialog box and prompt dialog box)
  • Displaying clocks etc.
  • avaScript Example

    1. <h2>Welcome to JavaScript</h2>  
    2. <script>  
    3. document.write("Hello JavaScript by JavaScript");  
    4. </script>  
    Test it Now

    Prerequisite

    Before learning JavaScript, you must have the basic knowledge of HTML.

    Audience

    We have developed this JavaScript tutorial for beginners and professionals. There are given a lot of examples with JavaScript editor. You will get point to point explanation of each JavaScript topics. Our tutorial will help beginners and professionals to learn JavaScript easily.

    Problem

    If there is any problem related to JavaScript, you can post your question in forum. We will definitely sort out your problems.
  • JavaScript Example

    Javascript example is easy to code. JavaScript provides 3 places to put the JavaScript code: within body tag, within head tag and external JavaScript file.
    Let’s create the first JavaScript example.
    1. <script type="text/javascript">  
    2. document.write("JavaScript is a simple language for javatpoint learners");  
    3. </script>  
    Test it Now
    The script tag specifies that we are using JavaScript.
    The text/javascript is the content type that provides information to the browser about the data.
    The document.write() function is used to display dynamic content through JavaScript. We will learn about document object in detail later.

    3 Places to put JavaScript code

    1. Between the body tag of html
    2. Between the head tag of html
    3. In .js file (external javaScript)

    1) JavaScript Example : code between the body tag

    In the above example, we have displayed the dynamic content using JavaScript. Let’s see the simple example of JavaScript that displays alert dialog box.
    1. <script type="text/javascript">  
    2.  alert("Hello Javatpoint");  
    3. </script>  
    Test it Now\

  • 2) JavaScript Example : code between the head tag

    Let’s see the same example of displaying alert dialog box of JavaScript that is contained inside the head tag.
    In this example, we are creating a function msg(). To create function in JavaScript, you need to write function with function_name as given below.
    To call function, you need to work on event. Here we are using onclick event to call msg() function.
    1. <html>  
    2. <head>  
    3. <script type="text/javascript">  
    4. function msg(){  
    5.  alert("Hello Javatpoint");  
    6. }  
    7. </script>  
    8. </head>  
    9. <body>  
    10. <p>Welcome to JavaScript</p>  
    11. <form>  
    12. <input type="button" value="click" onclick="msg()"/>  
    13. </form>  
    14. </body>  
    15. </html>  
    Test it Now
  • External JavaScript file

    We can create external JavaScript file and embed it in many html page.
    It provides code re usability because single JavaScript file can be used in several html pages.
    An external JavaScript file must be saved by .js extension. It is recommended to embed all JavaScript files into a single file. It increases the speed of the webpage.

    Let’s create an external JavaScript file that prints Hello Javatpoint in a alert dialog box.
    message.js
    1. function msg(){  
    2.  alert("Hello Javatpoint");  
    3. }  

    Let’s include the JavaScript file into html page. It calls the JavaScript function on button click.
    index.html
    1. <html>  
    2. <head>  
    3. <script type="text/javascript" src="message.js"></script>  
    4. </head>  
    5. <body>  
    6. <p>Welcome to JavaScript</p>  
    7. <form>  
    8. <input type="button" value="click" onclick="msg()"/>  
    9. </form>  
    10. </body>  
    11. </html>  
javascript tutorials javascript tutorials Reviewed by moviebuzz on August 03, 2018 Rating: 5

No comments:

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();
TECHHOW. Powered by Blogger.