Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » Internet & Web » Chapter 2: How to code a JavaScript application

Chapter 2: How to code a JavaScript application

This chapter presents a subset of JavaScript and DOM scripting that will soon have you writing significant applications. If you don't have any programming experience, this chapter also makes a great aptitude test. If you read it and can do the exercises at the end of the chapter, you're ready for the rest of this book.

Technologies: Internet & Web
Author Name: Ray Harris
Total downloads : 0
Total page views :  17089
Rating :
 0/5
This article has been rated :  0 times
  Add to Technorati Add to Technorati    Digg This Digg This    Add to del.icio.us Add to del.icio.us
    Rate this article Read/Post comments Support Us   Printable Version 

Chapter Contents
1. How to edit a web page with Notepad++
2. How to test a web page
3. How to display error messages in Firefox
4. How to include JavaScript with the script tag
5. How to code JavaScript statements
6. How to create identifiers
7. The primitive data types of JavaScript
8. How to code numeric and string expressions
9. How to declare variables and assign values to them
10. An introduction to objects, properties, and methods
11. How to use the window and document objects
12. How to use the Number, String, and Date objects
13. How to get and display data with a Textbox object
14. How to code conditional expressions
15. How to code if statements
16. How to code while and for statements
17. How to create and call a function
18. How to code an event handler
19. The Future Value application
20. Perspective

Become a Sponsor

How to edit and test your web pages

Before you can create a JavaScript application, you need to know how to edit and test a web page. To get you started, this topic provides the basic skills that you'll need. Then, in chapter 3, you'll learn more about testing and debugging.

How to edit a web page with Notepad++

Although you can use any text editor to enter and edit XHTML, CSS, and JavaScript files, using a better editor can speed development time and help reduce coding errors. Some features to look for in a text editor are syntax highlighting, auto-completion, and FTP access.

If you're using Windows, we recommend that you use Notepad++ as your editor because it provides all of these features. In addition to Notepad++, though, there are many other free and commercial text editors. For instance, Adobe Dreamweaver and Microsoft Expression Web Designer are two popular commercial editors. For the purposes of this book, however, Notepad++ provides all of the features that you'll need.

If you're a Mac OS user, we recommend that you use TextWrangler as your editor. This is a free editor that provides syntax highlighting and FTP access, although it doesn't provide auto-completion. Here again, though, you have other choices like commercial editors that do provide auto-completion. Three that do are BBEdit (the commercial version of TextWrangler), TextMate, and Dreamweaver.

To illustrate the use of a text editor for web pages, figure 2-1 shows Notepad++ as it's being used to edit a JavaScript file. As you can see, this editor provides tabs so you can edit more than one file at the same time. It color codes the syntax of the statements to reflect different coding elements. And its autocompletion feature helps you complete HTML, CSS, or JavaScript entries. If you experiment with Notepad++, you'll find that it has many other capabilities that this brief summary doesn't present.

Before you start using Notepad++, you should take the time to turn on the auto-completion feature. You will also want to change the style for comments because the default style is too small. These skills are summarized in this figure.

Then, when you start a new file, you should let Notepad++ know what language you're working with. To do that, you can either save the file with the .html, .css, or .js extension, or you can use the Language menu to select the language. Once you do that, this editor uses the appropriate color coding and auto-completion lists.

One feature not shown in this figure is how to access the files on an FTP server with Notepad++. To find out how to do that, you can search the Internet for "Notepad++ FTP".

Notepad++ with six tabs open and an auto-completion list displayed

How to open, save, close, and start files

  • To open a file, use the FileOpen command. Or, right-click on the file in the Windows Explorer and select the Edit with Notepad++ command. The file is opened in a new tab.
  • To save or close a file, select the tab that it's in and use the FileSave or FileClose command. Or right-click on the tab, and select the appropriate command.
  • To start a new file in a new tab, use the FileNew command.

How to change the style for comments

  • Start the SettingsStyler Configurator command, and select JavaScript in the language list and COMMENT in the style list. Then, change the font name and font size in the drop-down lists to the blank entries at the top of the lists.
  • Repeat this for COMMENTLINE and COMMENTDOC for the JavaScript language, for COMMENT for the HTML language, and for COMMENT for the CSS language.

How to use the auto-completion feature

  • To enable auto completion, use the SettingsPreferences command, click the Backup/Auto-completion tab, and check the "Enable Auto-completion on each input" box.
  • The auto-completion feature displays a list of terms that start with what you've typed. To insert one of those terms, double-click on it or use the arrows keys to highlight it and press the Tab key. To show the auto-completion list at any time, press Ctrl+Space.

How to let Notepad++ know which language you're working with

  • Notepad++ provides color coding for each of the languages that you'll be using: HTML, CSS, and JavaScript. For a new file, you can use the Language menu to select the language that you're using. Or, you can save the file with the appropriate extension.

Figure 2-1 How to edit a web page with Notepad++

Total Pages : 20 12345


        Rate this article Read/Post comments Support Us   Printable Version
 Book Detail
Book Title : http://www.murach.com/books/mdom/index.htm
Author: Ray Harris
Publisher: Murach
Price: 38.15 US$

Publisher Home Page: http://www.murach.com
Book Url: http://www.murach.com/books/mdom/index.htm
 Post a new question or comment about this article
Subject:
Comment:
 [Top] Rate this article:-
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
Latest Comments:
Subject Posted By Posted On
Support Us
Tell your friends about us
Is this article is a Bad Submission report us here
Submit articles, tutorials, and tips
Help by answering questions on our discussion forums
Help us correct errors and broken links
Looking for a job? Post your resume here
Looking for developers? Post your job here


 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2010.8.14
 © 2010  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.