How to Add JavaScript to HTML Documents
JavaScript is a programming language used on webpages for display on the Internet. JavaScript allows a programmer to create action or movement on websites. The script or program is sent over the Internet as code and is actually run on the client's computer. This method increases response time for the user and lowers the burden on the Web site hosting computers.
Instructions
-
-
1
Create a Web page using a HTML scripting program or text editor. The first line of code for any Web page is usually a statement about the coding standard used. A typical first line would read
'<'!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'>'. to indicate that the Web site will be W3 compliant in HTML 4.01 standard in English. -
2
Insert the standard header items of
'<'html'>'
'<'head'>', '<'title'>', Web site Page Title Goes Here '<'/title'>','<'/head'>'
'<'body'>'These tags are used to provide the typical information required at the top of each page.
-
-
3
Type the tag '<'script type="text/javascript"'>' to tell the browser that the next line(s) of code will be JavaScript. The code is based on specific action words that translate into specific actions in a Web browser. An example would be: document.write('Hello World!').
'<'/script'>' The browser will display "Hello World!" -
4
Accepted protocol for Web pages is to create a line of code that will inform the user why the page does not display correctly. The code used is '<'noscript'>'
Your browser either does not support JavaScript, or you have JavaScript turned off.
'<'/noscript'>'
Be sure to close off the script or code with closing tags. Standard formats are used to formally close the action that each tag or code opened. The standard HTML tags of
-
1