How to Create Java Script

How to Create Java Script thumbnail
JavaScript adds interactivity to otherwise static web pages.

Web designers use JavaScript to integrate effects and interactivity into web pages. This allows the designers to create something more appealing and engaging than a static web page. JavaScript is incorporated into the design of the web page itself.

Things You'll Need

  • Computer with a Web Browser (such as Internet Explorer or Firefox)
  • A text editor (such as notepad)
Show More

Instructions

    • 1

      Open the text editor (such as notepad on the Windows system). Web browsers read plain text documents created in text editors like notepad.

    • 2

      Enter the HTML and JavaScript into the text file. A minimal HTML file will look like this:

      <html>
      <body>

      This is my first web page!

      </body>
      </html>

      The <html></html> and <body></body> tags should always surround the content of the web page, including any embedded JavaScript.

    • 3

      Enter the JavaScript into the body of the HTML. The file will look like this:

      <html>
      <body>

      <script type="text/javascript">
      document.write("This is my first web page!");
      </script>

      </body>
      </html>

      The <script></script> tags must surround any JavaScript to tell the browser that it should execute the content in the tags as JavaScript. The "document.write("This is my first web page!")" statement tells the browser to write the sentence in the parentheses to the browser window.

    • 4

      Save the file in HTML format. The text editor will save files with the .txt file extension by default. This just means that the web browser will not read it as a web page. Save the file with the .html extension by clicking "File," then "Save As." In the "Save File" window that appears, highlight the name of the file in the "File Name" box towards the bottom. Rename the file "filename.html" (with the intended name replacing "filename" and quotation marks included).

    • 5

      Open the file in a web browser. In the web browser, click on "File," and "Open File," then navigate to the file and select it. The browser should open it like any other web page. The text should appear in the browser window, without the formatting tags.

Related Searches:

References

Resources

  • Photo Credit internet image by Attila Toro from Fotolia.com

Comments

You May Also Like

Related Ads

Featured