<<

INTERNET & WEB TECHNOLOGIES

by Abhilash Sahoo 1 Internet and Web Technologies

Chapter 1 | The Internet and WWW Internet

A vast network of interconnected computer systems which permit users to communicate and share information.

It is a network of networks that consists of millions of private and public, academic, business, and government networks of local to global scope that are linked by a broad array of electronic and optical networking technologies.

The Internet carries a vast array of information resources and services, most notably the interlinked hypertext documents of the (WWW) and the infrastructure to support electronic mail.

World Wide Web

The World Wide Web is a system of interlinked hypertext documents contained on the Internet. With a , one can view web pages that may contain text, images, videos, and other multimedia and navigate between them using hyperlinks.

Hypertext

Hypertext is text displayed on a computer with references (hyperlinks) to other text that the reader can immediately access, usually by a mouse click or keypress sequence. Apart from running text, hypertext may contain tables, images and other presentational devices.

A hypertext document consists of non‐linear text with to other text or documents. One navigates through hypertext by following the active links in the text.

Hyperlinks

A hyperlink, more commonly called a link, is an electronic connection between one to either (1) other web pages on the same web site, or

(2) Web pages located on another web site. More specifically, a hyperlink is a connection between one pages of a hypertext document to another.

Introduction: Web Architecture

One of the greatest things about the Internet is that nobody really owns it. It is a global collection of networks, both big and small. These networks connect together in many different ways to form the single entity that we know as the Internet. In fact, the very name comes from this idea of interconnected networks. 2 Internet and Web Technologies

The Internet: Computer Network Hierarchy

Internet Service Provider (ISP)

An Internet service provider (ISP, also called Internet access provider, or IAP) is a company or organization that has the equipment and telecommunication line access to provide connectivity to the Internet for customers. This is usually done for a set yearly or monthly fee.

Point of Presence (POP)

The POP is a place for local users to access the company's network, often through a local phone number or dedicated line.

Every computer that is connected to the Internet is part of a network, even the one in your home. For example, you may use a modem and dial a local number to connect to an Internet Service Provider (ISP). At work, you may be part of a local area network (LAN), but you most likely still connect to the Internet using an ISP that your company has contracted with. When you connect to your ISP, you become part of their network. The ISP may then connect to a larger network and become part of their network.

Most large communications companies have their own dedicated backbones connecting various regions. In each region, the company has a Point of Presence (POP). The amazing thing here is that there is no overall controlling network. Instead, there are several high‐level networks connecting to each other through Network Access Points or NAPs.

3 Internet and Web Technologies

When you connect to the Internet, your computer becomes part of a network.

DNS: Domain Name System

When the Internet was in its infancy, it consisted of a small number of computers hooked together with modems and telephone lines. You could only make connections by providing the IP address of the computer you wanted to establish a link with.

For example, a typical IP address might be 216.27.22.162. This was fine when there were only a few hosts out there, but it became unwieldy as more and more systems came online.

The first solution to the problem was a simple text file maintained by the Network Information Center that mapped names to IP addresses. Soon this text file became so large it was too cumbersome to manage. In 1983, the University of Wisconsin created the Domain Name System (DNS), which maps text names to IP addresses automatically. This way you only need to remember www.example.com, for example, instead of example.com's IP address.

URL: Uniform Resource Locator

When you use the Web or send an e‐mail message, you use a domain name to do it. For example, the Uniform Resource Locator (URL) "http://www.example.com" contains the domain name example.com. So does this e‐mail address: [email protected]. Every time you use a domain name, you use the Internet's DNS servers to translate the human‐readable domain name into the machine‐readable IP address.

Top‐level domain names, also called first‐level domain names, include .COM, .ORG, .NET, .EDU and .GOV. Within every top‐level domain there is a huge list of second‐level domains. For example, in the .COM first‐level domain there is:

Google Yahoo

Every name in the .COM top‐level domain must be unique. The left‐most word, like www, is the host name. It specifies the name of a specific machine (with a specific IP address) in a domain. A given domain can, potentially, contain millions of host names as long as they are all unique within that domain.

DNS servers accept requests from programs and other name servers to convert domain names into IP addresses. When a request comes in, the DNS server can do one of four things with it:

1 It can answer the request with an IP address because it already knows the IP address for the requested domain. 4 Internet and Web Technologies

2 It can contact another DNS server and try to find the IP address for the name requested. It may have to do this multiple times. 3 It can say, "I don't know the IP address for the domain you requested, but here's the IP address for a DNS server that knows more than I do." 4 It can return an error message because the requested domain name is invalid or does not exist.

Internet Protocol

Protocols

Protocols (rules determining the format and transmission of data) are often text and simply describe how the client and server will have their conversation.

Internet Protocol Suite

The Internet Protocol Suite (commonly known as TCP/IP) is the set of communications protocols used for the Internet and other similar networks. It is named from two of the most important protocols in it: the Transmission Control Protocol (TCP) and the Internet Protocol (IP), which were the first two networking protocols defined in this standard. Internet Protocol (IP)

The Internet Protocol (IP) is a protocol used for communicating data across a packet‐switched internetwork using the Internet Protocol Suite, also referred to as TCP/IP.

IP is the primary protocol in the Internet Layer of the Internet Protocol Suite and has the task of delivering distinguished protocol datagrams (packets) from the source host to the destination host solely based on their addresses.

Transmission Control Protocol (TCP)

The Transmission Control Protocol (TCP) is one of the core protocols of the Internet Protocol Suite. TCP provides a communication service at an intermediate level between an application program and the Internet Protocol (IP). That is, when an application program desires to send a large chunk of data across the Internet using IP, instead of breaking the data into IP‐sized pieces and issuing a series of IP requests, the software can issue a single request to TCP and let TCP handle the IP details.

TCP is used extensively by many of the Internet's most popular applications, including the World Wide Web, E‐mail, , Secure Shell, and some streaming media applications.

File Transfer Protocol

File Transfer Protocol (FTP) is a standard network protocol used to exchange and manipulate files over a TCP/IP based network, such as the Internet. FTP is built on client‐server architecture and utilizes separate control and data connections between the client and server applications. Applications were originally interactive command‐line tools with standardized command syntax, but graphical user interfaces have been 5 Internet and Web Technologies

developed for all desktop operating systems in use today

Hypertext transfer protocol (HTTP).

A protocol (utilizing TCP) to transfer hypertext requests and information between servers and browsers.

Hypertext Transfer Protocol (HTTP) is an application‐level protocol for distributed, collaborative, hypermedia information systems. Its use for retrieving inter‐linked resources, called hypertext documents.

There are two major versions, HTTP/1.0 that uses a separate connection for every document and HTTP/1.1 that can reuse the same connection to download, for instance, images for the just served page. Hence HTTP/1.1 may be faster as it takes time to set up such connections.

Request line, such as GET /images/logo.gif HTTP/1.1, which requests a resource called /images/logo.giffrom server

Ports and HTTP

Any server machine makes its services available using numbered ports: one for each service that is available on the server. For example, if a server machine is running a Web server and a file transfer protocol (FTP) server, the Web server would typically be available on port 80, and the FTP server would be available on port 21. Clients connect to a service at a specific IP address and on a specific port number.

Once a client has connected to a service on a particular port, it accesses the service using a specific protocol. Every Web server on the Internet conforms to the hypertext transfer protocol (HTTP).

Internet Servers and Clients

Internet servers make the Internet possible. All of the machines on the Internet are either servers or clients. The machines that provide services to other machines are servers. And the machines that are used to connect to those services are clients. There are Web servers, e‐mail servers, FTP servers and so on serving the needs of Internet users all over the world.

When you connect to example.com to read a page, you are a user sitting at a client's machine. You are accessing the example.com Web server. The server machine finds the page you requested and sends it to you. Clients that come to a server machine do so with a specific intent, so clients direct their requests to a specific software server running on the server machine. For example, if you are running a Web browser on your machine, it will want to talk to the Web server on the server machine, not the e‐mail server.

A server has a static IP address that does not change very often. A home machine that is dialing up through a modem, on the other hand, typically has a dynamic IP address assigned by the ISP every time you dial in. That IP address is unique for your session ‐‐it may be different the next time you dial in. This way, an ISP only needs one IP address for each modem it supports, rather than one for each 6 Internet and Web Technologies

customer.

Website and Web Pages

Webpage

A webpage or web page is a document or resource of information that is suitable for the World Wide Web and can be accessed through a web browser and displayed on a computer screen.

This information is usually in HTML or XHTML format, and may provide navigation to other webpages via hypertext links.

Webpages may be retrieved from a local computer or from a remote web server. The web server may restrict access only to a private network, e.g. a corporate intranet, or it may publish pages on the World Wide Web. Webpages are requested and served from web servers using Hypertext Transfer Protocol (HTTP).

These are of two types: 1. Static webpage

A static web page is a web page that always comprises the same information in response to all download requests from all users.

Classical web page design using only HTML or XHTML provides static content, meaning that a page retrieved by different users at different times is always the same.

Advantages

Quick and easy to put together, even by someone who doesn't have much experience. Ideal for demonstrating how a site will look. Cache friendly, one copy can be shown to many people.

Disadvantages

Difficult to maintain when a site gets large. Difficult to keep consistent and up to date. Offers little visitor personalization (all would have to be client side).

2. Dynamic Webpage

A dynamic web page is a hypertext document rendered to a World Wide Web user presenting content that has been customized or actualized for each individual viewing or rendition or that continually updates information as the page is displayed to the user.

However, a web page can also provide a live user experience. Content (text, images, form fields, etc.) on a web page can change, in response to different contexts or conditions. There are two ways to create this kind of effect: 7 Internet and Web Technologies

Using client‐side scripting to change interface behaviors within a specific web page, in response to mouse or keyboard actions or at specified timing events. In this case the dynamic behavior occurs within the presentation. Using server‐side scripting to change the supplied page source between pages, adjusting the sequence or reload of the web pages or web content supplied to the browser. Server responses may be determined by such conditions as data in a posted HTML form, parameters in the URL, the type of browser being used, the passage of time, or a database or server state.

Client‐Side Scripting

Client‐side scripting generally refers to the computer programs on the web that are executed at client‐side, by the user's web browser.

This type of computer programming is an important part of the Dynamic HTML (DHTML) concept, enabling web pages to be scripted; that is, to have different and changing content depending on user input, environmental conditions (such as the time of day), or other variables JavaScript (Client‐side JavaScript) and VBScript are examples of client‐side scripts.

Server‐Side Scripting

Server‐side scripting is a web server technology in which a user's request is fulfilled by running a script directly on the web server to generate dynamic web pages. It is usually used to provide interactive web sites that interface to databases or other data stores.

In contrast, server‐side scripts, written in languages such as Perl, PHP, and server‐side VBScript, are executed by the web server when the user requests a document.

Web Browser

A Web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web.

Although browsers are primarily intended to access the World Wide Web, they can also be used to access information provided by Web servers in private networks or files in file systems.

Microsoft

It is a series of graphical web browsers developed by Microsoft and included as part of the line of operating systems starting in 1995.The latest release is Internet Explorer 8, which is available as a free update for Windows XP with Service Pack 2 or later. 8 Internet and Web Technologies

Internet Explorer Ver. 8.0

Netscape Navigator

Netscape Navigator and Netscape are the names for the proprietary web browser popular in the 1990s, the flagship product of the Netscape Communications Corporation and the dominant web browser in terms of usage share, although by 2002 its usage had almost disappeared. One of the reasons for this was due to the popularity of Microsoft's Internet Explorer web browser software and other web browsers, and partly because the Netscape Corporation (later purchased by AOL) did not sustain Netscape Navigator's technical innovation after the late 1990s

Web Server

The primary function of a web server is to deliver web pages (HTML documents) and associated content (e.g. images, style sheets, ) to clients.

A client, commonly a web browser, makes a request for a specific resource using HTTP and, if all goes 9 Internet and Web Technologies

well, the server responds with the content of that resource. While the primary function is to serve content, a full implementation of HTTP also includes a way of receiving content from clients. This feature is used for submitting web forms, including uploading of files.

Many generic web servers also support server‐side scripting (e.g. Apache HTTP Server and PHP). This means that the behavior of the web server can be scripted in separate files, while the actual server software remains unchanged

Apache HTTP Server

The Apache HTTP Server commonly referred as Apache. Apache was the first viable alternative to the Netscape Communications Corporation web server (currently known as Sun Java System Web Server).

The application is available for a wide variety of operating systems, including Unix, GNU, FreeBSD, Linux, Solaris, Novell NetWare, Mac OS X, Microsoft Windows, OS/2, TPF, and eComStation. The majority of web servers using Apache run the Linux .

Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation. It has been the most popular HTTP server software in use. Features of Apace Server

1 Supports server‐side programming language and authentication schemes. 2 Virtual hosting allows one Apache installation to serve many different actual websites. For example, one machine with one Apache installation could simultaneously serve www.example.com, www.test.com, test47.test‐server.test.com, etc.

Uses of Apache Server

Apache is primarily used to serve both static content and dynamic Web pages on the World Wide Web. Many web applications are designed expecting the environment and features that Apache provides. Apache is used for many other tasks where content needs to be made available in a secure and reliable way. One example is sharing files from a personal computer over the Internet. A user who has Apache installed on their desktop can put arbitrary files in Apache's document root which can then be shared.

Chapter 2 | Introduction to HTML

What is Hypertext Markup Language?

HTML (Hypertext Markup Language) is the set of markup symbols or codes inserted in a file intended for display on a World Wide Web browser page. The markup tells the Web browser how to display a Web page's words and images for the user.HTML documents are also called Web Pages.

HTML Tags

HTML tags (otherwise known as "HTML elements"), and their respective attributes are used to create HTML documents so that you can view them in browsers. 10 Internet and Web Technologies

Complete list of HTML tags

Below is a complete list of HTML tags from the HTML 4.01 specification.

1. 31. 61.

2. 32.

62. 3. 33. 63.
 4.  34. 
64. 5. 35. 65. 6.
36. 66. 7. 37.

67.

Attributes specific to this tag:

name Defines the name of the parameter. src Specifies a URI/URL of an external script. language Specifies the scripting language. type Specifies the scripting language as a content‐type (MIME type). Declares that the script will not generate any content. Therefore, the browser/user defer agent can continue parsing and rendering the rest of the page.

Output will be: The HTML Script tag allows you to place a script within your HTML documents

21.

Attributes specific to this tag: 25 Internet and Web Technologies

disabled Specifies that a drop‐down list should be disabled multiple Specifies that multiple options can be selected Specifies the number of visible options in a drop‐down size list

21.

The HTML tabletag is used for defining a table. The table tag contains other tags that define the structure of the table. A simple HTML table consists of the table element and one or more tr, th, and td elements.

The tr element defines a table row, the th element defines a table header, and the td element defines a table cell.

Example

< td>$100
Month Savings
January
center right

bgcolor Specifies the background color for a table. border Specifies the width of the borders around a table. Specifies the space between the cell wall and the cell cellpadding content. cellspacing Specifies the space between cells.

22.

The HTML tag is used for specifying a cell (or table data) within a table. An HTML table has two kinds

of cells: 26 Internet and Web Technologies

Header cells ‐contains header information (created with the th element) Standard cells ‐contains data (created with the td element)

align Aligns the content in a cell left right center justify char

bgcolor Specifies a background color for a cell valign Vertical aligns the content in a cell top middle bottom baseline

cellpadding Specifies the space between the cell wall and the cell content nowrap Specifies that the content inside a cell should not wrap

22.

Attributes specific to this tag: 23. </p><p> name Assigns a name to the input control. rows Specifies the height of the textarea based on the number of visible lines of text. If there's more text than this allows, users can scroll using the textarea's scrollbars. cols Specifies the width of the textarea based on the number of visible character widths. </p><p>The HTML <title> tag is used for declaring the title of the HTML document. </p><p>The title is usually displayed in the browser's title bar (at the top). It is also typically used by search engines (to display the page title in the search results page) and browsers "favorites" lists. </p><p>Example <title>HTML title tag 27 Internet and Web Technologies

24.

The HTML tag is used for specifying a table row within a table. A table row contains one or more td and/or th tags which determine individual cells.

Example

Cell 1 Cell 2

25.

The HTML utag is used for rendering underlined text.

Example The HTML u tag renders underlined text.

Output will be: The HTML u tag renders underlined text.

Introduction: The Common Gateway Interface

1. Data Communication on the Web

A Web client program (such as a web browser) can access data from many different servers, such as FTP or HTTP. The HTTP server was designed specifically for the Web, and employs a protocol (system of messages) that supports sending documents from the server to a browser, and that also support sending complex data from the client back to the server. There are several HTTP methods for doing this. The most common methods are

• GET: the data are passed within the query string of the URL. For example, accessing the URL http://bla.bla.edu/stuff/program?query_string; sends the data included in query_string to the HTTP server running on the machine bla.bla.edu. POST: The data are sent as a message body that follows the request message sent by the client to the server. This is more complex than GET, but allows for more complex data.

The data can be sent from the client browser to the HTTP server. The Common Gateway Interface, or CGI, is the mechanism used by most servers to process these client data.

2. Server Processing of Passed Data: Gateway Programs

Sending data to the server is one thing, but in most cases the server cannot itself process the data, most HTTP server program are designed only to serve out documents, and are not designed to process data sent from a 28 Internet and Web Technologies

client. Therefore, if you want to do server‐side processing of the data sent from a fill‐in HTML FORM (or by any other mechanism), you need three things:

a second program to do process the data sent by the client, a mechanism by which the server can forward the data to this second program. Such secondary programs are called gateway programs, because they act as a gateway between the Web and other resources on the HTTP server machine, such as databases a way whereby this second program can return data to the client, so that the gateway program can return results of its analysis to the user.

An example of this of information is shown in the attached figure ‐‐the arrows show the flow of data, while the small ovals straddling the lines show the protocols and mechanisms by which the data are communicated from client(browser)‐to‐server‐to‐gateway and back again.

Figure: Flow of Data to Gateway Programs This figure illustrates the flow of data when a user accesses a CGI program. The solid line shows to data flow using HTTP and CGI. HTTP transfers data from the client to the HTTP server and back again. The CGI mechanisms control the flow of data from the server to the gateway program (shown as the prism) and back again. These are called gateway programs because they generally act as gateways between the World Wide Web and server‐side resources such as databases, feedback forms, clickable imagemaps, and so on.

3. The Common Gateway Interface

CGI (Common Gateway Interface) is the generic interface between the server and server‐side 'gateway' programs. CGI specifies how data are sent to the gateway program, and how data can be returned by the gateway program, through the server and back to the browser that originally sent the data. The basic mechanisms are:

1. Sending Data to the Gateway Program 29 Internet and Web Technologies

The CGI specifies how data are sent to the gateway program (as environment variables or as data read, by the gateway program, from standard input) and what data are sent (in general, all the data sent by the client to the server, plus extra environment variables describing the status of the server).

2. Returning Data to the Client

To return data back to the client program (the user's web browsers) the gateway program just writes data to its regular (standard) output. These data are sent back to the client, after some processing by the server to ensure they have the correct message headers describing the data and the state of the transaction. Illustration

The best way to illustrate this is with an example: A web page is created to add up numbers. The viewer enters in 2 numbers, and the webpage then adds up those numbers, and returns the answer to the viewer. HTML is not designed to process or calculate numbers, but what it can do, is pass those numbers to another program, and then accept an answer from that program for the viewer to see. So you really have 2 programs communicating with each other ‐one to calculate, and one to display (the HTML). Common Gateway Interface is the standard way for these programs to communicate.

4. Some more about Common Gateway Interface Web servers often have a cgi‐bin directory at the base of the directory tree to hold executable files called with CGI. The program returns the result to the web server in the form of standard output, prefixed by a header and a blank line.

5. Internal Workings of CGI So how does the whole interface work? Most servers expect CGI programs and scripts to reside in a special directory, usually called cgi‐bin, and/or to have a certain file extension. When a user opens a URL associated with a CGI program, the client sends a request to the server asking for the file.

For the most part, the request for a CGI program looks the same as it does for all Web documents. The difference is that when a server recognizes that the address being requested is a CGI program, the server does not return the file contents verbatim. Instead, the server tries to execute the program. Here is what a sample client request might look like:

GET /cgi-bin/index.pl HTTP/1.0Accept: www/sourceAccept: text/htmlAccept: image/gifUser-Agent: /2.4 /2.14From: [email protected]

This GET request identifies the file to retrieve as /cgi‐bin/index.pl. Since the server is configured to recognize all files in the cgi‐bin directory tree as CGI programs, it understands that it should execute the program instead of relaying it directly to the browser. The string HTTP/1.0 identifies the communication protocol to use.

The client request also passes the data formats it can accept (www/source, text/html, and image/gif), identifies itself as a Lynx client, and sends user information. All this information is made available to the CGI 30 Internet and Web Technologies

program, along with additional information from the server.

The server is then responsible for adding the complete header information and using the HTTP protocol to transfer the data to the client.

Here is the sample output of a program generating an HTML virtual document, with the complete HTTP header: HTTP/1.0 200 OKDate: Monday, 30-November-09 08:28:00 GMTServer: NCSA/1.4.2MIME-version: 1.0 Content-type: text/htmlContent-length: 2000 Welcome to Abhilash's WWW Server!

Welcome!

. .

6. Advantages of Common Gateway Interface 1. Language independent: CGI programs can be written in any language that allows one to write normal programs since they are executed in the same way as the normal programs. A CGI program can be written in any language that allows it to be executed on the system, such as:

C/C++ Fortran PERL TCL Any Unix shell Visual Basic AppleScript

1 Platform Independent: The popular Web servers developed their own extension mechanisms that allow third‐party software to run inside the web server itself, e.g. Apache modules, Netscape NSAPI plug‐ins, IIS ISAPI plug‐ins. 2 Simple interface: It’s not necessary to have any special library to create a CGI program, or write programs using a particular API. Instead, CGI programs rely on the standard concepts of standard input, standard output, and environment variables to communicate with the Web server.

7. Drawbacks of Common Gateway Interface 1 CGI call involves use of a scripting language such as csh or perl, coding errors are highly likely to result in a code injection vulnerability. 2 One disadvantage is that CGI programs are slow since they need to form a new process for every HTTP request and the database connection must be reopened for the next instance of the program, which is quite costly.

Basic JavaScript

JavaScript is a very easy way to add all sorts of dynamic elements to your website. Unless you've had some programming experience, JavaScript will be quite a new concept at the start — it's fairly different to HTML. In this chapter we'll be laying some groundwork on the language, and writing our first script. 31 Internet and Web Technologies

What is JavaScript? JavaScript is a simple scripting language invented specifically for use in web browsers to make websites more dynamic. On its own, HTML is capable of outputting more‐or‐less static pages. Once you load them up your view doesn't change much until you click a link to go to a new page. Adding JavaScript to your code allows you to change how the document looks completely, from changing text, to changing colours, to changing the options available in a drop‐down list (and much, much more!)

JavaScript is a client‐side language, which means all the action occurs on the client's (reader's) side of things. JavaScript operations are usually performed instantaneously. In fact, JavaScript is often used to perform operations that would otherwise encumber the server, like form input validation. This distribution of work to the relatively quick client‐side service speeds up the process.

The Java Connection Understandably, JavaScript's connection with Java is regularly misunderstood. They are not the same thing.

Java, created by Sun Microsystems, is a full computer programming language like C++, suitable for writing complete, large‐scale programs. JavaScript, on the other hand, was created by Netscape. It was based to some degree on Java — the syntax of the code is very similar — but it is very rarely used for anything outside of a browser. It was actually originally to be called 'Live Script', but Java's increasing popularity at the time made Netscape change the name for marketing reasons.

Similarities:

They are both forms of Object‐Oriented Programming, or OOP. This means that you work with small objects that are combined together to form larger objects.

Scripting language or Script

A scripting language is a programming language; that can be interpreted by a browser without needing to be compiled first. The script is actually just some commands that the browser has to do.

Implementation

So how are we going to get our JavaScript into our pages? JavaScript is written in the same way as HTML — in a text‐editor. JS implementation is quite easy; you can link to outside files (with the file extension .js), or write blocks of code right into your HTML documents with the 32 Internet and Web Technologies

When you place that in your code the text Hello World will appear on your screen wherever you put it. Like so:

Hello World!

Let's break this down a bit. The script tag encloses any script code you want to use. The typeattribute we have in their alert the browser to the type of script it is about to deal with (there are others, like VBScript), and so helps it to interpret the code.

External Scripts

To import scripts from external JS files, save the code in a text file with the .js extension; without the script tags and comments. In this case the code would just be the document.write("Hello World!"); part (although this won't do much on its own). We then link to this document, in the page's , with

We should always place includes in the head so that the browser is ready to execute scripts when the user calls for them. If a user clicked a button that called for a script that the browser wasn't aware of yet, you'd get an error. Having them in the head means they're always ready before they're needed.

A Simple Script

So what did our code above actually accomplish? Take another look at it.

We start by taking control of the document object, and use its write() method to output some text to the document. The text inside the double quotes is called a String, and this string will be added to the page. Simple, right? To use an object's methods or properties, we write the object's name, a dot, and then the method/property name. Each line of script ends with a semicolon (;). JavaScript isn't very forgiving; if you make any mistakes in typing this out, you'll get a script error, so code carefully.