<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Lisa Wollin : JavaScript 101</title><link>http://blogs.msdn.com/lisawoll/archive/tags/JavaScript+101/default.aspx</link><description>Tags: JavaScript 101</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>JavaScript 101: Working with Events</title><link>http://blogs.msdn.com/lisawoll/archive/2005/07/13/438591.aspx</link><pubDate>Thu, 14 Jul 2005 01:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:438591</guid><dc:creator>lisawoll</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/438591.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=438591</wfw:commentRss><description>&lt;p&gt;It has been awhile since my last JavaScript 101 post. I apologize. I have a 
very lame excuse: I've been busy. But I'm back with the next installment: working 
with events.&lt;/p&gt;
&lt;p&gt;Most JavaScript events are relatively simple and easy to use. For example, 
clicking on a button, an element, or a page. There are some more complex events 
that deal with data, but to keep this simple, I'll talk only about the ones that 
affect user interaction, such as onclick, onmouseover, onmouseout, and onfocus. 
There are, of course, many more events than this, but these four events seem 
to cover a majority of the uses that you will need ... at least to start with.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;The Script&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;First, of course, you need a script, so here's a simple little script.&amp;nbsp; 
All it does is display a message box.&amp;nbsp; Just copy the code below, including 
the opening and closing &amp;lt;script&amp;gt; tags, and paste them into the HEAD section of a 
Web page.&lt;/p&gt;
&lt;pre&gt;&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;
function ShowMessage(text)
{
    window.alert(text);
}
&amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;p&gt;In order to call a script from an event, it must be inside a function, so the 
above script contains a function called &amp;quot;ShowMessage&amp;quot; that takes one argument, 
the text to be displayed.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;As I mentioned in 
&lt;a href="http://blogs.msdn.com/lisawoll/archive/2005/05/23/421105.aspx" target="_blank"&gt;my last 
JavaScript 101 post&lt;/a&gt;, you can use IntelliSense in Code view in 
FrontPage to write your scripts.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;The HTML&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Second, you need to reference the function from an event inside of an 
element. I'll use a P element. Here's the 
HTML code that you need.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;p&amp;gt;Here is a sample paragraph 
with an event.&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Putting Them Both Together&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Next, add to the P element a an event handler that calls the function.&amp;nbsp; You can add it to 
any event, such as the onload event, but to make things simple, add it to the 
onclick event.&amp;nbsp; Here's the code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;onclick=&amp;quot;ShowMessage
('A little JavaScript fun!');&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Your P element should now look like the following code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;p oncl&amp;shy;ick=&amp;quot;ShowMessage
('A little JavaScript fun!');&amp;quot;&amp;gt;
Here is a sample paragraph with 
an event.&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And that's it.&amp;nbsp; Save your page and display it in the browser.&amp;nbsp; 
When you click on the text in the paragraph, the browser displays a message like 
the one in the following image.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.wollinweb.com/blogimages/js101events.gif"&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;What You've Learned&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;In this post you learned how to hook up a JavaScript function with an event 
handler for an HTML element. Now that you understand how to hook your scripts up 
to events to create user interaction, we can move onto writing more scripts.&amp;nbsp; 
Next time, I'll talk about working with text—things like changing the text or HTML in an element, 
changing colors, formatting, etc. Until then, have fun!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=438591" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript+101/default.aspx">JavaScript 101</category></item><item><title>JavaScript 101: Writing Your First Script</title><link>http://blogs.msdn.com/lisawoll/archive/2005/05/23/421105.aspx</link><pubDate>Mon, 23 May 2005 23:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:421105</guid><dc:creator>lisawoll</dc:creator><slash:comments>42</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/421105.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=421105</wfw:commentRss><description>&lt;P&gt;You can arm yourself with all the background information that you want, but the easiest way to learn JavaScript is to just jump in and start writing code. So let's start with something simple for your first script.&lt;/P&gt;
&lt;P&gt;The window object contains all the other objects in the DOM, plus properties, methods, and events for the browser window. A common task that people want to do is specify the text for the status bar. Here's a simple bit of code that does this.&lt;/P&gt;&lt;CODE&gt;window.status = "This is a sample for changing the text on the status bar."&lt;/CODE&gt; 
&lt;P&gt;This example is very simple, but simple is a great way to start.&lt;/P&gt;
&lt;P&gt;Now that you have the code, what do you do with it? This is a great beginner question. There are two ways to insert JavaScript code into your pages. (1) You can insert raw JavaScript code into a &amp;lt;script&amp;gt; tag in the HEAD section of a page. (2) You can place the code in a function and put the function in a &amp;lt;script&amp;gt; tag in the HEAD section of a page, and then add an event handler to call the function.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;(1) insert raw JavaScript code&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;For now, let's stick with the simplicity of the first option. Use the following steps to add this code to a page.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Start a new page in FrontPage and switch to Code view. (You can also use the code window in Split view.) 
&lt;LI&gt;In Code view, locate the closing &amp;lt;/head&amp;gt; tag. (If you don't know HTML, there's never been a better time to learn. Check out the &lt;A href="http://office.microsoft.com/en-us/training/CR061832701033.aspx"&gt;HTML tutorials&lt;/A&gt; on Office Online and &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnarhtmau/html/beghtml.asp"&gt;HTML for Beginners&lt;/A&gt; on MSDN.) 
&lt;LI&gt;Press Enter a couple times and position the Insertion Point (cursor) on one of the blank lines. 
&lt;LI&gt;Copy the following code and paste it into FrontPage at the Insertion Point.&lt;BR&gt;&lt;CODE&gt;&amp;lt;script language="javascript"&amp;gt;&lt;BR&gt;window.status = "This is a sample for changing the text on the status bar."&lt;BR&gt;&amp;lt;/script&amp;gt;&lt;/CODE&gt; 
&lt;LI&gt;Save the page and preview it in a browser. Your page should look just like the following image (status bar text is circled in red to make it easy to locate). &lt;/LI&gt;&lt;/OL&gt;
&lt;BLOCKQUOTE&gt;&lt;IMG src="http://www.wollinweb.com/blogimages/statusbar.gif"&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The second way to insert a script (i.e., place the code a function and put the function in a &amp;lt;script&amp;gt; tag in the HEAD section of a page, and then add an event handler to call the function.) requires a bit more work, so let's split it up into three separate tasks&lt;/P&gt;
&lt;P&gt;&lt;B&gt;(2) place the code in a function&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Put simply, a function is a section of code that runs separately from code around it. Essentially, functions are methods that you create yourself to perform some action or series of actions. Some functions return values; other functions require values passed into them. The values that functions return are called return values; values passed into functions are called arguments.&lt;/P&gt;
&lt;P&gt;The structure, or syntax, of a function is always the same: the function keyword identifies that what follows is a function, the text that follows the function keyword identifies the name of the function, the name of the function is followed by opening and closing parentheses (which may or may not contain arguments), and the code that applies to the function appears inside of opening and closing curly braces.&lt;/P&gt;
&lt;P&gt;Here's a simple diagram of the syntax of a function:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.wollinweb.com/blogimages/function.gif"&gt;&lt;/P&gt;
&lt;P&gt;For those of you who prefer to cut and paste, here's a code version of the above.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;function scriptName()
{
    //Code goes here
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using the example above, your function might look something like the following code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;script language="javascript"&amp;gt;
    function changeStatus() 
    { 
        window.status = "This is a sample for changing the text on the status bar."
    }
&amp;lt;/script&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When you place JavaScript code in functions, you can call the functions from event handlers. Event handlers execute code based on certain events that occur within the browser. I'll talk more about events and event handlers in my next post; for now, I want to show you how IntelliSense in FrontPage can help you write scripts.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Using IntelliSense in FrontPage&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;IntelliSense provides cues to options (or in this case objects, methods, properties, and events) that may be available. Let's go back to the code that we used earlier and create this again in FrontPage (without cutting and pasting the code).&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Using IntelliSense to insert HTML Elements&lt;/B&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;To begin, start FrontPage and start a new page. 
&lt;LI&gt;Switch to Code view. 
&lt;LI&gt;Position the Insertion Point (cursor) before the closing &amp;lt;/head&amp;gt; tag and press Enter a few times. 
&lt;LI&gt;Move the Insertion Point up a couple lines and type "&amp;lt;s". As you type, a drop-down box, as shown in the following image, displays showing a list of elements that can be placed within the HEAD section of a Web page.&lt;BR&gt;&lt;IMG src="http://www.wollinweb.com/blogimages/intellisense.gif"&gt;&lt;BR&gt;As you type, the highlighted element moves to "script"; at this point you can press the spacebar (or Enter or Tab) to insert the element into your Web page. 
&lt;LI&gt;After you press the spacebar, you see a list of attributes that apply to the SCRIPT element. Type "langu"; again, as you type, the highlighted attribute changes from &lt;B&gt;lang&lt;/B&gt; to &lt;B&gt;language&lt;/B&gt;. (We need the &lt;B&gt;language&lt;/B&gt; attribute to identify that we are using JavaScript.) 
&lt;LI&gt;When the &lt;B&gt;language&lt;/B&gt; attribute is highlighted, type an equals sign (=) and a double quote ("). 
&lt;LI&gt;Now you see a list of possible values for the &lt;B&gt;language&lt;/B&gt; attribute. Type "j", and the highlighted value moves to "javascript". 
&lt;LI&gt;Type a closing double quote (") and a closing angled bracket (&amp;gt;). FrontPage automatically inserts the closing &amp;lt;/script&amp;gt; tag. 
&lt;LI&gt;You should now have the following code in your Web page:&lt;BR&gt;&lt;CODE&gt;&amp;lt;script language="javascript"&amp;gt;&amp;lt;/script&amp;gt;&lt;/CODE&gt; &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;When you use IntelliSense to insert HTML elements, FrontPage places the Insertion Point between the opening and closing tags. You can then type text or, in this case, code between the tags.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Using IntelliSense to write JavaScript code&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Now that you have an opening and closing script tag, you can write your script code. &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;With the Insertion Point between the opening and closing &amp;lt;script&amp;gt; tags, press enter a couple times. Arrow up once so that your Insertion Point is on the line that is between the line that contains the opening script tag and the line that contains the closing script tag. 
&lt;LI&gt;Type "window."; don't forget the period after the window. Once you press ".", FrontPage shows a drop-down list that contains all the properties, methods, and events related to the window object, as shown in the following image.&lt;BR&gt;&lt;IMG src="http://www.wollinweb.com/blogimages/intellisense2.gif"&gt; 
&lt;LI&gt;Type "st" and then press Tab. FrontPage inserts "status" into your script. Now your script should read: &lt;CODE&gt;window.status&lt;/CODE&gt; 
&lt;LI&gt;Press the space bar and type an opening quote. 
&lt;LI&gt;Type "This text displays on the browser's status bar.", and then type a closing quote. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The only thing to understand about using IntelliSense for writing scripts is that IntelliSense doesn't work when you are working with variables because FrontPage doesn't know which object a variable represents. I'll tell you more about declaring and working with variables a bit later. For now, try using IntelliSense to insert your own simple scripts. Here are a few to get you started:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;CODE&gt;window.alert("here's a message");&lt;/CODE&gt; 
&lt;LI&gt;&lt;CODE&gt;window.resizeTo(640,480);&lt;/CODE&gt; 
&lt;LI&gt;&lt;CODE&gt;window.moveTo(0,0);&lt;/CODE&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;
&lt;P&gt;These are just a few simple scripts; in a future post, I'll help you understand how to write your own more complex scripts.&lt;/P&gt;
&lt;P&gt;Here's what you learned today:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Woohoo! You wrote your first scripts. 
&lt;LI&gt;You learned how to use IntelliSense in FrontPage. 
&lt;LI&gt;You learned how to create a JavaScript function. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;In my next post, I'll tell you more about events and how to connect a JavaScript function to an event on a Web page. For now, have fun.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=421105" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript+101/default.aspx">JavaScript 101</category></item><item><title>JavaScript 101: The JavaScript Object Model</title><link>http://blogs.msdn.com/lisawoll/archive/2005/04/05/405744.aspx</link><pubDate>Wed, 06 Apr 2005 07:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:405744</guid><dc:creator>lisawoll</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/405744.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=405744</wfw:commentRss><description>&lt;FONT face=verdana&gt;
&lt;P&gt;If you talk to several different Web developers, each will probably see the JavaScript object model differently. To make it easiest, I'm going to split the JavaScript object model into two separate entities. One is the DOM, or Document Object Model, and the other is "everything else."&lt;/P&gt;
&lt;P&gt;&lt;B&gt;The DOM&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Let's first start with the DOM. The DOM, also sometimes called the DHTML object model, is generally used to create dynamic HTML (DHTML). The DOM is made up of objects and members (by "members" I mean methods, properties, and events) that allow you to change the appearance of a Web page by using code. A drop-down menu is an example of using scripting with the DOM to manipulate the visible state of a DIV element. The following image shows the core objects in the DOM.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.wollinweb.com/blogimages/jsdom.gif"&gt;&lt;/P&gt;
&lt;P&gt;Periodically, I'll refer back to this image as I break down the different objects of the DOM. For now, just notice the hierarchical structure of the DOM.&lt;/P&gt;
&lt;P&gt;Different browsers implement the DOM differently. For example, an object that you can access in one browser may not be available in another browser. The above diagram includes only core objects and not custom objects that are included only in one or a few browsers. For example, the Layer object only works in Netscape Navigator, and possibly Mozilla and Firefox by association, and not in Internet Explorer. By the same token, Internet Explorer may implement its own custom objects that are unavailable in non-Microsoft browsers. For this reason, if you want your scripts to run in all possible browsers, you should stick with the core objects and not use custom objects, which may make programming scripts easier but will cause problems for your users.&lt;/P&gt;Scripting against objects or using methods, properties or events that are not implemented in all browsers causes a run-time scripting error, like the one shown in the following image, when displaying a page in a browser in which the object or member is not available.&lt;BR&gt;&lt;BR&gt;&lt;IMG src="http://www.wollinweb.com/blogimages/jserror.gif"&gt; &lt;BR&gt;&lt;BR&gt;You have probably seen similar error messages. Sometimes, the cause is that there is an error in the code, but most often, the programmer scripted against an object or member that isn't available in your browser. 
&lt;P&gt;&lt;B&gt;Everything Else&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Next, the "everything else" that I mentioned.&amp;nbsp; Everything else includes objects to handle strings, numbers, and boolean values as well as mathematical functions and arrays. I generally consider these less "objects" and more as language conventions and built-in functions, but I'll explain that a bit later. For now, I'd like to focus on working with the DOM since those are the objects that most client-side JavaScript uses (although you can use the math functions to calculate numbers, which you might get from a Web form, but that's a subject that deserves its own post, so for now forget I mentioned it).&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Working with the DOM&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;As I already said, the objects in the DOM are the objects that you would generally use to animate Web pages using client-side scripting. The main top-level object is the window object. All other objects are what are called "child" objects of this object because they exist as "children" of this object. This can be easier to understand if you think of the above diagram like a family tree. The window is the top-level "parent" object with "child" objects named document, event, history, location, navigator, and screen. The document object is a "child" object that is also a "parent" object because it has "child" objects, as does the form object.&lt;/P&gt;
&lt;P&gt;The relationship between parent and child objects in an object model give the objects a structure that you can easily navigate, and understanding this structure helps you determine how to access child objects, which makes editing and writing scripts easier. You can work with most child objects of the window object directly without accessing them from the window object. &lt;/P&gt;
&lt;P&gt;When you access individual objects within this hierarchical structure, you need to separate each object (and/or member) with a period (.). For example, the following code accesses the BODY element of the document object that is a child of the window object.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;window.document.body&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, as I mentioned above, the document object is one of the child objects of the window object that you can access without first accessing the window object. So this code could also be written as shown in the following code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;document.body&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;B&gt;Note&lt;/B&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;You may have noticed that there isn't a body object in the object hierarchy shown in the image. This is correct. You'll also notice that I said that the code accesses the BODY "element" not the body object. The &lt;CODE&gt;body&lt;/CODE&gt; in the above code is an accessor property that returns an element object. (If you've forgotten what an accessor property is, see my previous post &lt;a href="http://blogs.msdn.com/lisawoll/archive/2005/03/23/400837.aspx" target=_blank&gt;JavaScript and OOP&lt;/A&gt;.) &lt;/P&gt;
&lt;P&gt;All HTML elements (with the exception of the elements that have specific objects in the object model, like the STYLE and FORM elements) use the element object. However, not all elements have properties that you can use to access them directly. (In fact, most do not.) The BODY element just happens to be one of the few that does. I'll explain in a future post how to access all the other elements.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Whew! This was a lot of general, overview-type stuff to take in in one sitting, and you might be thinking what on earth you're going to do with all of it. Well, I don't expect it to gel completely just yet, but soon it will all make sense and you'll be writing your own scripts like a pro.&lt;/P&gt;
&lt;P&gt;For now, here's what you learned today about JavaScript:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;JavaScript has objects that you can use to animate Web pages (DOM) as well as objects that you can use to calculate numbers, handle strings, and work with arrays ("everything else"). 
&lt;LI&gt;The DOM contains objects that you can use to access features in a browser and elements in a Web page. 
&lt;LI&gt;You use the DOM objects to create dynamic HTML pages. 
&lt;LI&gt;The DOM has a hierarchical structure that is similar to a family tree and is made up of "parent" and "child" objects. 
&lt;LI&gt;Understanding the hierarchical structure of the DOM helps you know how to access the appropriate child objects and makes writing scripts easier. 
&lt;LI&gt;In script, you need to separate objects in the hierarchical structure with a period (.). &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;In my next post, we'll write a few simple scripts and I'll show you how IntelliSense in FrontPage can help you write your scripts.&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=405744" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript+101/default.aspx">JavaScript 101</category></item><item><title>JavaScript 101: JavaScript and OOP</title><link>http://blogs.msdn.com/lisawoll/archive/2005/03/23/400837.aspx</link><pubDate>Wed, 23 Mar 2005 07:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:400837</guid><dc:creator>lisawoll</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/400837.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=400837</wfw:commentRss><description>&lt;p&gt;As I mentioned in the previous post, &lt;A href="http://blogs.msdn.com/lisawoll/archive/2005/03/16/396878.aspx" target="_blank"&gt; JavaScript 101: An Introduction&lt;/a&gt;, JavaScript is an Object Oriented Programming (OOP) language, and as such, it is comprised of objects. A bunch of objects bundled together is called an object model, also called an application programming interface (API). Each object in an object model has characteristics that describe it — properties, actions that you can take against it — methods, and actions that happen in response to other actions — events.&lt;/p&gt; &lt;p&gt;JavaScript is admittedly not as robust as most compiled OOP languages; the object model is simple by comparison, but in order to write, modify, or even reuse someone else's JavaScript code, you should understand the basics of an object model.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Properties&lt;/b&gt; — Properties describe the characteristics of an object. To use the car analogy that I used in the previous post, a car has characteristics, or properties, like make, model, and color. Often, properties have a single value. For example the make property of the car object might have a value of &amp;quot;Dodge&amp;quot;; the model property might have a value of &amp;quot;Durango&amp;quot;; and the color property might have a value of &amp;quot;Red.&amp;quot; Properties can also be objects. These are called &amp;quot;accessor properties&amp;quot; because they access another object. In our car analogy, the car object might have a steeringWheel property that accesses a steeringWheel object, and the steeringWheel object may have its own set of properties, methods, and events.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Methods&lt;/b&gt; — Methods are actions that you can take against an object. To continue the car analogy, actions that you can perform with a car might be start, drive, and get a tune up. Some methods return values; other methods require values passed into them. For example, the start method of the car object might return a true or false (boolean value), and the tuneup method might require passing in a date for when the tune up occurs. The values that methods return are called return values; values passed into methods are called arguments. &lt;/p&gt; &lt;blockquote&gt; &lt;b&gt;Note&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;The term &amp;quot;parameters&amp;quot; is also often used to refer to the values passed into methods. The actual definitions of these two terms differ somewhat, but a complete discussion of these differences are beyond the scope of this discussion. I'll explain these terms a bit later.&lt;/blockquote&gt; &lt;p&gt;&lt;b&gt;Events&lt;/b&gt; — Events are actions that happen in response to other actions. The car analogy works here, also. For example, the car object might have an event named die to handle the possibility of the engine quitting unexpectedly, or it may have a crash event to handle the possibility if the car is involved in an accident.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Collections&lt;/b&gt; — Another part of an object model is collections. Collections are comprised of one or more instances, or copies, of the same object.&amp;nbsp; For example, in the car analogy, a car object might have a tires collection that has five instances of the tire object (with one tire object having the isSpare property set to true).&lt;/p&gt; &lt;p&gt;Don't worry if this all seems confusing. I'll explain properties, methods, events, and collections a bit more when I discuss specific objects in the JavaScript object model. However, before I describe the objects in the JavaScript object model, there are a few things you need to understand first. I will describe some of these in greater detail later, but you will need at least a general understanding of these before moving onto the specifics of the JavaScript object model.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Variables&lt;/b&gt; — In programming, variables are considered temporary storage. The can represent objects or data, such as strings or numbers.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Data types&lt;/b&gt; — Simply put, data type indicates the type of data in a variable. The three basic data types in JavaScript are strings, numbers, and booleans. String variables contain text, number variables contain ... well ... numbers, and boolean variables indicate true/false, on/off, and yes/no conditions.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Case sensitivity&lt;/b&gt; — JavaScript is case sensitive. This means that JavaScript considers the word &amp;quot;doc&amp;quot; and the word &amp;quot;Doc&amp;quot; as two different words and not the same word.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Arrays&lt;/b&gt; — Arrays are variables that contain multiple values of the same type. For example, an array of numbers could contain the values 1, 3, 45, 50, and 69 all within the same variable name. JavaScript programmers frequently use arrays to store multiple values.&lt;/p&gt; &lt;p&gt;So the things you learned about JavaScript in this post are&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The JavaScript object model (or application programming interface) is comprised of objects, collections, properties, methods, and events.&lt;/li&gt; &lt;li&gt;Properties describe characteristics of an object.&lt;/li&gt; &lt;li&gt;Methods perform actions against an object.&lt;/li&gt; &lt;li&gt;Events handle actions that are performed against an object.&lt;/li&gt; &lt;li&gt;Variables are temporary storage.&lt;/li&gt; &lt;li&gt;Data types indicate the type of data contained in variables.&lt;/li&gt; &lt;li&gt;JavaScript is case sensitive.&lt;/li&gt; &lt;li&gt;Arrays contain multiple values of the same type.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;This is a lot of information, but I think we're through with the basics. Next post, I'll diagram the specific objects in the JavaScript object model.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=400837" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript+101/default.aspx">JavaScript 101</category></item><item><title>JavaScript 101: An Introduction</title><link>http://blogs.msdn.com/lisawoll/archive/2005/03/16/396878.aspx</link><pubDate>Wed, 16 Mar 2005 17:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:396878</guid><dc:creator>lisawoll</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/396878.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=396878</wfw:commentRss><description>&lt;p&gt;Many visitors to the MSDN FrontPage developer portal are unfamiliar with programming, so I decided that the best way to help non-developers understand our developer content is to provide education. This is the first installment, and its purpose is to teach JavaScript to the non-developer. The JavaScript 101 series is not designed for developers, as most of our developer content is, so it may be far too simple for a seasoned JavaScript developer. However, if you are either new to JavaScript or completely unfamiliar with JavaScript, this series is for you. For a list of all the posts in this series, scroll down the page and click JavaScript 101 under Post Categories.&lt;/p&gt; &lt;p&gt;Before I start on the programming end of JavaScript, I wanted to explain the purpose of JavaScript and a bit of the background. Last summer, we published an article titled &lt;a href="http://msdn.microsoft.com/office/understanding/frontpage/gettingstarted/default.aspx?pull=/library/en-us/odc_fp2003_ta/html/odc_fpgettingstartedwithwebdev.asp" target="_blank"&gt;Introduction to Web Development&lt;/a&gt; that described the various languages and technologies that Web developers may encounter and need to use. After a description of what programming languages are and how they are used on the Internet, the article gave the following description for JavaScript:&lt;/p&gt; &lt;blockquote&gt;JavaScript is an interpreted scripting language commonly used on the Internet for creating Web pages that respond to user actions, such as when a user moves a mouse pointer over an image or clicks a form button. Combined with HTML and CSS, JavaScript allows you to create Dynamic HTML pages. &lt;p&gt;JavaScript is generally used for client-side scripting; as a result, users can easily view JavaScript code along with the HTML code in a page. Although it may be used for server-side scripting, JavaScript works best for visual animation (such as changing an image when a user moves the mouse pointer over it) or for validating form fields.&lt;/p&gt; &lt;p&gt;Various browsers may implement the JavaScript scripting objects differently, but most popular browsers support JavaScript.&lt;/p&gt; &lt;p&gt;The biggest disadvantage of JavaScript is that users can turn it off in the browser, which makes pages that use it not function as expected.&lt;/p&gt; &lt;p&gt;Netscape developed the JavaScript programming language. JScript is the Microsoft implementation of ECMAScript, as defined by the specification of Ecma International. Both JavaScript and JScript are ECMAScript-compliant languages.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;As the article mentions, there are basically two types of programming languages: compiled and interpreted. Most programs have .exe files. An .exe file is where the code that runs a program lives, and usually you can double-click an .exe file to start a program. (For example, if you use Windows Explorer to locate FPage.exe and double-click it, FrontPage starts.) Compiled programming languages require a language compiler to create the .exe files. Interpreted programming languages aren't compiled into .exe files but require an interpreter to understand the code.&lt;/p&gt; &lt;p&gt;Much like you may need an human interpreter to understand a natural language (such as Danish or Swahili), browsers need a JavaScript interpreter to understand JavaScript code. As the preceding quote mentions, JavaScript is an interpreted language and a JavaScript interpreter lives inside most browsers, so when you write JavaScript code, you don't need to buy an interpreter to run the code. Instead, the interpreter sees the code and in effect tells the browser what to do with it. Some browsers don't understand JavaScript code. For example, older browsers that were developed before JavaScript was invented obviously wouldn't support it. Plus, most browsers allow the user to turn off JavaScript. In both of these cases, the user wouldn't receive an error; your code just doesn't run.&lt;/p&gt; &lt;p&gt;Because JavaScript usually runs in a browser, it's also called client-side scripting. You can use other languages for client-side scripting, but no client-side language is as universally accepted as JavaScript or understood in more browsers. This is why most Web developers use JavaScript to animate their Web pages using Dynamic HTML (DHTML). DHTML allows you to respond to the actions of your users; thus the term "dynamic."&amp;nbsp; For example, when a user moves her mouse over an element on a page, you may want to perform an action, such as displaying an element that was previously hidden (as is usually the case with drop-down menus). Or when a user clicks the Submit button on a form, you may want to verify that he has entered all the necessary information in the fields.&lt;/p&gt; &lt;p&gt;JavaScript is also termed an object-oriented programming (OOP) language. OOP is a programming paradigm that differs from traditional programming in that it separates elements of an application into discrete elements. I'll explain OOP a little bit at a time, especially as it relates to JavaScript, because it can be quite confusing when taken as a whole; however, the simplest explanation is this: OOP uses objects, and objects are basically things — specifically, things as they relate to an application. For example, think of an object, or thing, that you use every day: your car. Cars have values that describe them, such as make/model and color, and you can perform certain tasks with them, like start and drive them.&lt;/p&gt; &lt;p&gt;Before you begin pulling your hair out and yelling "I don't care about OOP or that JavaScript is an interpreted language; all I want to do is add this little bit of code to my page," let me assure you that this information is very important. The first JavaScript book I ever read never made one mention of OOP. I felt like I had watched a game and missed the winning play. Without this information you may be able to incorporate scripts that others have written into your page, but you will never be able to troubleshoot the code, and I promise you that you will at some point need to do that. So please bear with me. This introduction (and the one or two topics that follow) is critical to helping you understand what you need to know to not only incorporate scripts into your page but also write a few scripts of your own. However, I promise that this info won't be book-length. I'll include only the information you need to be able to move forward.&amp;nbsp;Promise!&lt;/p&gt; &lt;p&gt;So the things you learned about JavaScript in this post are&lt;/p&gt; &lt;ul&gt; &lt;li&gt;JavaScript is an interpreted programming language. &lt;li&gt;JavaScript is a scripting language that you can use for client-side scripting. &lt;li&gt;You can use JavaScript to animate Web pages using DHTML. &lt;li&gt;JavaScript allows you to respond to user actions. &lt;li&gt;JavaScript is an OOP (object-oriented programming) language. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Next time I'll talk a little more about JavaScript as an OOP language.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=396878" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript+101/default.aspx">JavaScript 101</category></item></channel></rss>