• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL



Congratulations on your decision to learn JavaScript and JScript. JavaScript is a powerful scripting language that, when combined with HTML, allows you to create exciting and powerful Web pages. You can use these Web pages to run a small business or to share information with family and friends over the Internet. JScript is a Microsoft implementation of JavaScript that can be used as a scripting language for automating repetitive or complex desktop and system tasks.

What you are probably asking yourself is, “Can I really learn to program using JavaScript and JScript in a single weekend?” The answer is “Yes!” I am not promising that you will become a programming guru in just a few days, but if you will dedicate a full weekend to this book and follow along with its examples, you will be able to write your own JavaScripts and JScripts. In no time you will be able to make dramatic improvements to your Web pages as well as develop scripts that automate any number of Windows desktop tasks.

Syntactically, JavaScript and JScript are virtually identical. So by learning how to write JavaScripts, you are also learning how to work with JScript as well. Where the two languages differ is in the environments in which they execute. JavaScripts are embedded inside HTML pages and run by Web browsers. JScripts, on the other hand, are written as plain text files that are executed directly from the Windows desktop by the Windows Script Host or WSH.

As long as you have basic Windows skills and a good HTML background, you’ll find that this book will provide you with all the information and examples you need to get up and running with both of these exciting scripting languages in a single weekend.

What This Book Is About

This book is about learning how to write JavaScripts in order to create exciting Web sites. It is also designed to teach you how to leverage the skills and knowledge that you’ll develop working with JavaScript in order to create JScripts that automate desktop tasks. Basic experience with Windows and HTML is assumed. The book provides the rest for you. By the time the weekend is over, you will have learned how to do the following:

  • Integrate JavaScripts into your Web pages

  • Use JavaScript to take control of the browser status line

  • Use JavaScript to display pop-up alert, prompt, and confirmation dialog boxes so that you can interact with your visitors

  • Use JavaScript to add graphic effects to Web pages

  • Use JavaScript to create Web page banners, clocks, and other animation effects

  • Use JavaScript to validate forms and e-mail the contents of those forms to yourself

  • Write JavaScripts that collect and save visitor information

  • Write JScripts that automate Windows tasks, such as the creation of new user accounts and disk and printer management

  • Write JScripts that can read text files and create log and report files

  • Write JScripts that can create shortcuts and configure the Windows Start menu and Quick Launch bar

Who Should Read This Book?

This book is for anyone who is ready to begin spicing up their Web pages using JavaScript, or anyone who wants to become more efficient by learning how to automate the execution of repetitive or complex Windows tasks. Before working with JavaScript, you’ll need to be comfortable working with Netscape Navigator or Microsoft Internet Explorer. Of course, you’ll need to know a little HTML as well. Likewise, you’ll need to know the basics of working with Windows in order to be able to leverage the power of JScript. This means that you should already know how to perform such tasks as well as know how to create a shortcut, how to create, delete, and modify text files and folders in addition to knowing how to configure the Windows Start menu.


If you feel that your HTML skills are a little weak, you might want to brush up on them by reading Premier Press’s Learn HTML In a Weekend. However, if you are only a little rusty, you’ll probably be able to pick things back up by reviewing the HTML code used in this book.

It is also helpful (but not required) that you know another programming language such as Basic, Perl, or C. This book provides an ideal quick start guide for more seasoned programmers. Although knowledge of another computer programming language is not a prerequisite for success, having this type of background will make your learning experience this weekend a little easier and less stressful. Do not worry if you lack this experience; everybody has to start somewhere. JavaScript and JScript are perfect languages to start with.

What You Need to Begin

The great thing about JavaScripts and JScripts is that they are easy to create. You do not have to spend a lot of money on programming tools before you can begin developing scripts. To begin developing JavaScripts, all that you’ll need is

  • A computer. Just about any computer will work because you don’t need a lot of horsepower to develop and test JavaScripts.

  • Internet access. Whether it is from work or home, you must be able to access the Internet so that you can upload your Web pages to your Web site.

  • An Internet Web browser. Several Internet browsers support JavaScript, including Microsoft Internet Explorer, Netscape Navigator, and Opera. You need at least one of these browsers to test your JavaScripts. However, it’s a good idea to have copies of all of them to make sure that your JavaScripts work correctly with each browser.

  • A Web site. If you do not already have your own Web site, the odds are that your local Internet service provider can set you up with one.

  • A text editor. You can use any basic text editor to write and save your JavaScripts. You can even use the Windows Notepad application.

  • A graphics editor. This tool is optional, though it is required if you plan to add any graphic images to your Web pages. For example, you might want to design your own banner pages or Web site logo.

Unlike many programming languages, JScript doesn’t require you to learn how to work with a complicated integrated development environment or IDE before you can develop scripts that run directly from the Windows desktop. To begin developing JScripts, all that you’ll need is

How This Book Is Organized

This book is written so that you can complete it in seven sessions over the course of a single weekend. Of course, you can read it anytime you want. The first five chapters focus on providing you with a strong JavaScript programming foundation. The last two chapters leverage this material by teaching you how to apply what you have learned to the development of JScripts. The basic outline of the book is shown here:

  • Friday Evening:Introducing JavaScript and JScript.” This chapter provides prerequisite background information for working with JavaScript and JScript. It overviews the kinds of enhancements you can make to Web pages using JavaScript. Background information includes a brief history of JavaScript and a discussion of browser compatibility. You’ll then learn how to write your first JavaScript. This chapter also includes an overview of JScript and the WSH. This will include an overview of both technologies and a brief examination of the WSH architecture, which provides the environment in which JScripts execute.

  • Saturday Morning:Learning the Basics of JavaScript Coding.” This chapter provides you with a programming foundation. It discusses scripting and script syntax before starting a series of lessons that outline the basic programming statements that comprise the JavaScript and JScript languages. You will learn how to work with variables, literals, functions, expressions, operators, statements, and arrays. The chapter concludes by covering object-oriented programming and outlining the JavaScript object model.

  • Saturday Afternoon: “Using JavaScript to Build Better Web Pages.” This chapter reviews objects made available to JavaScript by browsers and demonstrates how to access these objects. The chapter also provides a discussion on JavaScript events and how to handle them with event handlers. The chapter concludes with a discussion on how to use JavaScript to control HTML frames and forms.

  • Saturday Evening:Doing Really Cool Things with Your Web Pages.” In this chapter, things start getting really exciting. You’ll learn how to write JavaScripts that manipulate the browser status line, create scrolling messages, and open pop-up dialog boxes. The chapter includes a discussion on the differences between Netscape Navigator and Internet Explorer and how to work with both browsers using JavaScript. The chapter concludes by covering the use of plug-ins and the application of graphics and animation.

  • Sunday Morning:Advanced JavaScript Coding.” This chapter concludes the book’s JavaScript coverage by exploring how to use cookies to store and retrieve information about visitors to your Web site. The chapter also provides a solid review of the techniques involved in debugging JavaScripts. Finally, the chapter ends by demonstrating how to put your new JavaScript programming skills to use by developing the On-line Bookmall Web site.

  • Sunday Afternoon: “Learning How to Use JScript and the WSH.” This chapter covers the objects that make up the WSH object model, including their properties and methods. It also goes over JScript’s runtime objects. It teaches you how to write JScripts that can access the Windows file system and shows you different ways of performing file and folder administration. You’ll learn how to create text documents and log files as well as how to open and read text files.

  • Sunday Evening: “Using JScript to Automate Windows Tasks.” This chapter focuses on showing you how to use JScript and the WSH to perform a number of different automation tasks. These tasks will include the creation of Windows shortcuts, the customization of the Windows Start menu and Quick Launch Toolbar, how to write messages to the Windows Event Log, and how to read and write to the Windows registry. In addition, you will learn how to work with Windows commands, access network resources, and schedule script execution.

  • What’s on the Web Site?” This tells you where you can find examples of all the scripts that are presented in this book. Copies of each are available for download from http://www.courseptr.com.

  • Glossary: This presents a list of terms used throughout this book.


    Please go to http://www.courseptr.com to find Appendixes A, B, and C.

  • Appendix A:A Brief JavaScript and JScript Object Reference.” This appendix provides a brief outline of JavaScript objects and identifies the properties and methods associated with them.

  • Appendix B:A Summary of JavaScript Events and Event Handlers.” This appendix provides a brief outline of JavaScript events and the event handlers associated with them.

  • Appendix C:JavaScript and JScript Reserved Words.” This appendix identifies JavaScript and JScript reserved words.

Special Features of This Book

This book applies a number of conventions to help make it easier for you to use, including


  • Notes provide additional information that is good to know but which may not be essential to the topic being discussed.



  • Tips suggest alternative techniques and shortcuts that can help you to work faster and more efficiently.



  • Cautions warn you of situations where errors or unforeseen problems could arise.

  • Italics are used to highlight new terms and emphasize key pieces of information.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint