• About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy Policy
  • Change the purpose of use

Tnhelearning.edu.vn - Various useful general information portal

  • Photo
  • Bio
  • How To
  • Tech

How to Add JavaScript to an HTML Website

February 20, 2024 by admin Category: How To

You are viewing the article How to Add JavaScript to an HTML Website  at Tnhelearning.edu.vn you can quickly access the necessary information in the table of contents of the article below.

X

This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

This article has been viewed 11,269 times.

This wikiHow teaches you how to add the JavaScript scripting language to an HTML web page.

Table of Contents

  • Steps
  • Warning

Steps

Image titled 864267 1

Image titled 864267 1

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/f/f5/864267-1.jpg/v4-728px-864267-1.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/f/f5/864267-1.jpg/v4-728px-864267-1.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Open a simple text editor. Notepad on Windows and TextEdit on Mac are document editors designed specifically for and integrated with the operating system.

  • On Windows operating systems, type Notepad in the Start menu search box to locate Notepad on your computer, then click Notepad when the application appears in the results.
  • On Mac, click the magnifying glass icon in the upper-right corner of the screen, type TextEdit in the search box, then click TextEdit when the app appears in the results.
Image titled 864267 2

Image titled 864267 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/3/33/864267-2.jpg/v4-728px-864267-2.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/3/33/864267-2.jpg/v4-728px-864267-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Start HTML version. Compose HTML tags, including the header pair <head> and </head> , along with the body tag pair <body> and </body> . Compose all the necessary tags to start a website as follows:

     < html > < head > </ head > < body > </ body > </ html > 
Image titled 864267 3

READ More:   How to Develop Communication Skills

Image titled 864267 3

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/2/24/864267-3.jpg/v4-728px-864267-3.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/2/24/864267-3.jpg/v4-728px-864267-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Add the script tag to the head of the HTML. Insert the <script language=”javascript”> tag in the header. This tag tells the editor that you want to use the JavaScript language to “program” HTML JavaScript. In this example, we will greet the user using the alert tag.

  • Add a script tag to the head HTML of your website to insert JavaScript.
  • If you want the script to run automatically when the page is being loaded then don’t include the input feature. If you want to access the script, insert the feature.
  •  < html > < head > < script language = "javascript" > alert ( "Welcome to the site." ) < / script > < / head > < body > </body> </ html > 
Image titled 864267 4

Image titled 864267 4

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/2/2c/864267-4.jpg/v4-728px-864267-4.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/2/2c/864267-4.jpg/v4-728px-864267-4.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Use the JavaScript feature to retrieve the JavaScript script. If you know where the script file can be found, add the src= attribute to the script tag and include the complete web page address for the JavaScript file.

  • When retrieving scripts on your website, you need to make sure you set up a direct link to the Javascript file and not to the URL or other page where the script is being called.
  •  < html > < head > < script type = "text/javascript" src = " http://www.cpagrip.com/script_include.php?id=2193 " > </script> < / head > <body> < / body > </ html > 
Image titled 864267 5

Image titled 864267 5

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/6/6c/864267-5.jpg/v4-728px-864267-5.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/6/6c/864267-5.jpg/v4-728px-864267-5.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Click File in the menu bar, choose Save As… (for Windows) or Save (for Mac) to save the file.
Image titled 864267 6

Image titled 864267 6

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/6/66/864267-6.jpg/v4-728px-864267-6.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/6/66/864267-6.jpg/v4-728px-864267-6.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Click .html in the format drop-down panel.
Image titled 864267 7

READ More:   What does FWB mean on social media, messaging and dating apps?

Image titled 864267 7

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/e/e7/864267-7.jpg/v4-728px-864267-7.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/e/e7/864267-7.jpg/v4-728px-864267-7.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
Name the document and click Save .
  • Image titled 864267 8

    Image titled 864267 8

    {“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/de/864267-8.jpg/v4-728px-864267-8.jpg”,”bigUrl”:”https:// www.wikihow.com/images/thumb/d/de/864267-8.jpg/v4-728px-864267-8.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,” bigHeight”:546,”licensing”:”<div class=”mw-parser-output”></div>”}
    Double-click the file to open the document in the browser.
  • Warning

    • You must specify the MIME tag type on the HTML4 standard. Proceed by inserting the “type=’text/javascript'” attribute in the <script> tag. You do not need to specify an attribute type for the HTML5 standard.
    • On standard HTML3, instead of inserting “type=’text/javascript'”, insert “language=’javascript'”.
    X

    This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

    The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

    This article has been viewed 11,269 times.

    This wikiHow teaches you how to add the JavaScript scripting language to an HTML web page.

    Thank you for reading this post How to Add JavaScript to an HTML Website at Tnhelearning.edu.vn You can comment, see more related articles below and hope to help you with interesting information.

    Related Search:

    Related Posts

    How to Create Curved Text in Photoshop
    How to fall asleep faster
    How to Install FBReader to Read eBooks

    Category: How To

    Previous Post: « How to Change Tires
    Next Post: How to Remove iCloud Activation Lock on iPhone or iPad »

    Copyright © 2025 · Tnhelearning.edu.vn - Useful Knowledge