JavaScript « Web Development « Java Articles

Home
Java Articles
1.Build Deploy
2.Class
3.Core Library
4.Data Types
5.Database JDBC
6.Design
7.Development
8.File Input Output
9.Graphics Desktop
10.J2EE Enterprise
11.J2ME Wireless
12.JVM
13.Language
14.Library Product
15.Network
16.Security
17.SOA Web Services
18.Test
19.Web Development
20.XML
Java Articles » Web Development » JavaScript 

1. Create reusable routines in JavaScript    javaworld.com

When learning a new programming language, one of the first things you should do is create commonly used "plug-and-play" routines. If you're new to JavaScript, you might want to consider starting with a half-dozen or so simple routines that you think might be helpful. Even if you don't end up using them, you'll learn a lot about JavaScript in the process.

2. Understanding and using JavaScript statements    javaworld.com

JavaScript currently supports the following eleven statements. Note that some of these -- such as comment, var, and new -- aren't bona fide statements, but they are often treated as such. They are included in this discussion for the sake of completeness.

3. JavaScript and Netscape Frames    javaworld.com

With JavaScript, this control becomes even more useful. Although the browser cannot re-render a page that has already been brought up, you can send the other frames off to display new URLs or information. You can also access resources such as input fields and other form elements in the other frames. With this you can set events to change information in the other frames easily. We will quickly go over the Netscape FRAME system so that I know that we're on the same track. If you're going to use JavaScript, this new document system will come in very handy.

4. Bending over backward to make JavaScript work on 14 platforms    javaworld.com

BE: A lot of our content people are getting into JavaScript and Frames -- you can see their work at http://proto.netscape.com. I have many customers internal to our product development organization, including new server projects, the LiveWire team, and client folks who are helping to make Navigator more scriptable in future releases.

5. Debugging JavaScript programs    javaworld.com

Debugging a JavaScript program entails using problem-solving techniques that would impress Sherlock Holmes. Effective debugging of JavaScript requires some experience writing programs for it. After a while, you become familiar with the error messages JavaScript displays and learn ways to solve the errors. Of course, you may not have the time to devote yourself to learning all the intricacies of JavaScript. This column is your quick-reference guide to understanding how to effectively debug JavaScript programs, even without a debugging utility.

6. Bruce Johnson on writing JavaScript in a Java IDE    javaworld.com

Google Engineering Manager Bruce Johnson explains the steps involved in writing an Ajax application using your favorite Java IDE and Google Web Toollkit, in this talk with LinuxWorld Editor Don Marti.

7. Take advantage of user-defined variables in JavaScript    javaworld.com

(Note: As with most modern programming languages, JavaScript supports array variables in addition to the basic scalar variables used to hold the above data types. We'll concentrate on single-value variables for this column and devote a separate column to arrays.)

8. New JavaScript features in Navigator 3.0    javaworld.com

Rather, it's the inside that's different, in ways the casual observer cannot see. One of the major improvements in Netscape 3.0 is JavaScript, the built-in scripting language that provides for interactive and intelligent control over the HTML content of a page. JavaScript is more mature and refined this time around, with many of its "version 1.0" bugs squashed. What's more, JavaScript supports a number of enhancements, including new object constructors, in-place image replacement, and direct communication between it and Java applets and plugins. Though JavaScript is far from being complete, it has taken another step in becoming a world-class user scripting language.

9. Is JavaScript here to stay?    javaworld.com

While the idea behind JavaScript is a noble one, as a Little Engine it's already showing signs of running out of steam. At least temporarily. JavaScript is an integral part of Netscape's much-heralded troika of enabling technologies -- the other two are Java and plugins -- so it's unlikely that JavaScript will derail any time soon. As Netscape is a company often with an extra ace or two up its sleeve, there's no telling what grand future plans they have for JavaScript.

10. JavaScript Column    javaworld.com

Debugging JavaScript programs Everyone makes mistakes writing JavaScript programs. Errors don't know experts from novices, so the next time you get an error message while trying to play a JavaScript program you've written, don't feel bad. JavaScript provides error messages as a means to help you spot mistakes. This column describes the errors you are likely to get when writing a JavaScript program and what to do about them. Gordon Mccomb, July 1996

11. Expressing yourself in JavaScript    javaworld.com

This explanation may sound complex, but as you will soon see, an expression is really nothing more than a simple formula for addition. This column addresses the use of expressions in JavaScript, both for defining the content of variables, as well as for creating more elaborate schemes using other JavaScript constructs. Used in this way, expressions provide a way for your scripts to think on their own (although they may seem to act on their own more than you'd like them to!).

12. Cooking with JavaScript & DHTML, Part 3    onjava.com

Our latest sample recipe from JavaScript & DHTML Cookbook comes from Chapter 5 on "Browser Feature Detection." Learn how to detect object property and method support, thereby ensuring complete support for modern scriptable features. And check back here next week for a sample recipe on importing browser- or operating system-specific style sheets.

13. Cooking with JavaScript & DHTML, Part 5    onjava.com

Sites Beautiful Code Databases Digital Media Emerging Telephony Inside Aperture Inside Lightroom Inside Port 25 InsideRIA.com LinuxDevCenter.com MacDevCenter.com ONJava.com ONLamp.com Apache BSD MySQL PHP Python Perl.com Ruby SysAdmin What Is? WindowsDevCenter.com XML.com WebServices.XML.com

14. JavaScript: Windows and Frames    onjava.com

Sites Beautiful Code Databases Digital Media Emerging Telephony Inside Aperture Inside Lightroom Inside Port 25 InsideRIA.com LinuxDevCenter.com MacDevCenter.com ONJava.com ONLamp.com Apache BSD MySQL PHP Python Perl.com Ruby SysAdmin What Is? WindowsDevCenter.com XML.com WebServices.XML.com

15. Cooking with JavaScript & DHTML, Part 4    onjava.com

Editor's note: Short and sweet: that's what our latest sample recipe from JavaScript & DHTML Cookbook is: a quick and simple solution to importing browser- or operating system-specific style sheets. This week's excerpt is from Chapter 11 on "Managing Style Sheets." And next week's recipe will also come from the same chapter--check back here then to learn how to read effective style sheet property values.

16. Cooking with JavaScript & DHTML, Part 2    onjava.com

Sites Beautiful Code Databases Digital Media Emerging Telephony Inside Aperture Inside Lightroom Inside Port 25 InsideRIA.com LinuxDevCenter.com MacDevCenter.com ONJava.com ONLamp.com Apache BSD MySQL PHP Python Perl.com Ruby SysAdmin What Is? WindowsDevCenter.com XML.com WebServices.XML.com

17. Cooking with JavaScript & DHTML    onjava.com

Editor's note: This sample recipe is the first of six we've excerpted from JavaScript & DHTML Cookbook. We'll be running one per week over consecutive weeks so check back to this space often for recipes that cover arrays and objects; browser feature detection; style-sheet management; and HTML elements positioning. Today's recipe is from Chapter 8 on "Dynamic Forms."

18. Cooking with JavaScript & DHTML, Part 6    onjava.com

Editor's note: In this sixth and final sample recipe excerpted from JavaScript & DHTML Cookbook, Danny Goodman shows you how to determine the location of a nonpositioned element. And if you've enjoyed sampling the recipes presented thus far, we'll have another tempting morsel for you to sink your teeth into. Danny has written a bonus recipe you won't find in the book. Check back here in two weeks to try it out.

19. Dynamic Database Access from Client-Side JavaScript    onjava.com

Imagine the advantages of being able to dynamically access a database from client-side JavaScript. You could dynamically query a database from JavaScript for client-side field validation, or dynamically populate a drop-down select list, to name just a few possibilities. In fact, you can do this, with the help of an applet-servlet pair (assuming you can constrain your users to compatible browsers, i.e., IE and Netscape.) This article describes the applet-servlet pair architecture and offers several sample applications.

20. Object Oriented JavaScript Demonstrated    theserverside.com

Before diving into the object-oriented features of JavaScript, let's first take a look at some of the basics. This chapter walks you through:

21. Linking Javascript Objects with HTML Controls    javareport.com

TYING JAVASCRIPT OBJECTS TO HTML CONTROLS Now that we know how to define our own JavaScript objects and how JavaScript creates objects for HTML elements, the question is, how do we tie the HTML-derived objects to our custom-made JavaScript objects? The answer is, event handlers. Almost all HTML controls have the ability to receive events from the Web browser and call a JavaScript function in response. All we need to do is plug our objects into the appropriate event handler and the rest will happen automatically. For example, let's take the simple object we created in our last installment ("anObject") and tie it to an HTML button. The code to do this is shown in Listing 2. The part we are interested in here is the "" tag. Notice the "onClick" handler? It's telling the browser that, when the user clicks on this button, it should call the "sayHello" method of the object named "myObj." That's all there is to it! A JAVASCRIPT check box OBJECT Now that we can link JavaScript objects to HTML controls, let's look at a more complex task: using JavaScript to make HTML controls easier to use. For this, let us consider the lowly check box. HTML check boxes are rather simple things, but it can still be a pain to manage a large number of them. By creating a JavaScript check box object, we can use the same code to manage any number of HTML check boxes. The JavaScript code for a check box object is rather simple. The constructor is shown in Listing 3. As expected, this isn't an overly complicated object. It has two instance variables and three methods. THE "form" AND "name" VARIABLES To truly "link" a JavaScript object to an HTML control, you must be able to access that control from your JavaScript code. To do that, you have to know two things about the control: the name of the HTML form it is in and the name of the HTML control itself. The "form" and "name" instance variables allow us to keep track of this information for each control. (We've looked at this concept before.2) Once we have this information, we use it to access our control by using JavaScript's "eval" method. The eval method takes a string representing a valid JavaScript statement and executes it as if it had been hard-coded in your HTML file. So, for example, the statement: eval( "alert( 'Hello World!')"); will display an alert window with the string "Hello World!" in it, just as if you had coded: alert( 'Hello World!') By keeping the name of our form and the name of our control inside our object, we can create statements that, when passed to the eval method, let us access our HTML control. For example, in the code we will look at in a moment, our form is named "oCheckBoxExample," and our first check box control is named "testBox1." Inside the "oCheckBoxIsChecked" method, you will see the line of code:

22. Tech Giants Woo Developers Seeking JavaScript Turf    javareport.com

Both products allow developers to use their existing expertise in Java (GWT) or in .NET-supported languages (Volta) to write applications that will run on any device supporting JavaScript.

23. Enhancing HTML controls with JavaScript objects    javareport.com

We examined a JavaScript object for enhancing HTML check boxes in the April 1999 column. 1 This time, we're going to use these concepts along with some new JavaScript objects to enhance three HTML controls: radio buttons, select lists, and text boxes. THE oRadio OBJECT HTML radio buttons are like check boxes that are kept in herds. Radio buttons are organized into "families," and only one radio button in each family can be on at any given time. The main reason to use a JavaScript object with a radio button family is to simplify the management of multiple radio buttons and/or families. In fact, a single JavaScript radio button object is all you need to manage an entire family of radio buttons no matter how many buttons are in the family. For example, if you have 100 radio buttons organized into two families of 50 buttons each, you would only need two JavaScript objects to manage all 100 buttons!

24. NetBeans 6.1 Beta Features New JavaScript, Ruby and Spring Support    javareport.com

The new version of NetBeans features a number of improvements, such as the addition of JavaScript technology features to support AJAX-based Web applications, plus tighter MySQL database integration, the company said. JavaScript improvements include code completion, semantic highlighting and type analysis, among others.

25. JavaScriptingBuilding a JavaScript object browser    javareport.com

One such tool is a simple JavaScript object browser. The basis of this tool is the JavaScript for/in statement. This statement allows you to execute a set of statements for each and every property of an object. For example, consider the code shown in Listing 1. This simple program will loop through the properties of the built-in navigator object and write the name of each property to the browser window. (If this doesn't seem like a useful thing to do, try loading this page into various Web browsers. You might be very surprised by what you see!)

26. Mastering Dojo: JavaScript and Ajax Tools for Great Web Experiences    artima.com

Dojo is a set of client-side JavaScript tools that help you build better web applications. Dojo blurs the line between local, native applications and browser-based applications; the browser becomes the user interface platform.

27. JavaScript and PHP Support in NetBeans 6.1    artima.com

In the past two years, NetBeans has become a multi-lingual IDE, supporting not only Java, C, and C++, but also Ruby and, with the recent release of NetBeans 6.1, PHP and JavaScript as well. Support for working with those languages in the IDE goes far beyond syntax highlighting. The IDE tries to understand as much about the code's structure as it can, and provides intelligent refactorings, code completion, and the ability to work with multiple languages within one source file.

28. Prototype and script.aculo.us: You never knew JavaScript could do this!    artima.com

Dive into Prototype, the library that makes JavaScript so much more powerful, and it looks a lot like Ruby code. Exploring the DOM, handling events, taming AJAX, and radically simplifying most of your scripting code: it all becomes easy and very portable with Prototype.

29. Compiling Java to JavaScript    artima.com

Have an opinion about the Google Web Toolkit or about Java-to-JavaScript compilation? Discuss this article in the Articles Forum topic, Compiling Java to JavaScript.

30. JavaScript as a Foundation Language for Your Web Apps    devx.com

This article explains why JavaScript is perfectly suited as a core, foundation language for your web applications. It introduces the lesser known and yet most powerful JavaScript features, and demonstrates how to leverage them to increase your productivity.

31. Integrate XForms with the Google Web Toolkit, Part 1: Introducing GWT's JavaScript Native Interface    ibm.com

The Google Web Tookit (GWT) has become a very popular way to develop Ajax applications. It allows Java developers to rapidly create Ajax applications by leveraging their knowledge of Java? technology without requiring any knowledge of JavaScript. XForms represents an evolution in the HTML standard, and allows for simple constructs to create complex, dynamic behavior. Both GWT and XForms are powerful enough to provide complete solutions to many problems. So what about using them together? That's exactly what this series is going to show.

32. The cranky user: Curbing JavaScript dependency    ibm.com

In summary, JavaScript should always be optional for users. Dependency on it cannot improve a page; it can only cripple it. In particular, be wary of the possibility that your tools will be creating a dependency when you're just looking for an enhancement. Enhancement is harmless and will not generally offend people. Don't tell people they have to use JavaScript to view your page; it's rude, and it won't win you any customers.

33. Finite state machines in JavaScript, Part 2: Implement a widget    ibm.com

Part 1 asserted that JavaScript is well-suited as an execution environment for finite state machines, and mentioned some of its capabilities that were relevant to the design phase. In this article, you will work through the details of translating your design into JavaScript, taking advantage of some elegant language features, and accommodating some inelegant details that make the implementation tricky.

34. Mastering Ajax, Part 2: Make asynchronous requests with JavaScript and Ajax    ibm.com

To make all this flash and wonder actually happen, you need to become intimately familiar with a JavaScript object called XMLHttpRequest. This little object -- which has actually been around in several browsers for quite a while -- is the key to Web 2.0, Ajax, and pretty much everything else you learn about in this column for the next several months. To give you a really quick overview, these are just a few of the methods and properties you'll use on this object:

35. Use functional programming techniques to write elegant JavaScript    ibm.com

Functional programming languages have been in academia for quite some time, but historically they do not have extensive tools and libraries available. With the advent of Haskell in the .NET platform, functional programming is becoming more popular. Some traditional programming languages, such as C++ and JavaScript, import constructs and features from functional programming. In many cases, repetitive code in JavaScript leads to clumsy coding. You can avoid all that if you use functional programming. Also, you can write more elegantl callbacks with a functional programming style.

36. Ajax and Java development made simpler, Part 1: Generate JavaScript code dynamically with JSP tag files    ibm.com

This first article in the four-part series presents a JSP-based technique for generating JavaScript code, significantly reducing the amount of code you have to write manually. The sample application shows how to generate JavaScript functions for sending Ajax requests and processing Ajax responses. You can use the simple techniques discussed here in a real application if you want to be able to change the Ajax code easily. The broader goal of this article is to demonstrate how to use JSP tag files to produce JavaScript code for any purpose, not just Ajax routines.

37. JavaScript and the Document Object Model    ibm.com

Note:This article uses a DOM-compatible browser such as Netscape 6.x, Internet Explorer 6, or Mozilla 1.0. Familiarity with the Document Object Model in Java technology or other languages, is helpful, but not required. You should, however, be familiar with JavaScript in general.

38. JavaScript EE, Part 1: Run JavaScript files on the server side    ibm.com

In this first article of the series, you will use a simple script runner that lets you execute JavaScript files within a Java EE application. Scripts will have access to the so-called "implicit objects" that are used in JSP pages, such as application, session, request, and response. Most of the samples consist of reusable code so that you can easily start using JavaScript on the server in your own applications.

39. Finite state machines in JavaScript, Part 3: Test the widget    ibm.com

In this final article you'll test the implementation in some popular browsers. You need to construct a simple test page that creates some FadingTooltip widgets and binds them to HTML elements. For comparison, your test page will also illustrate some built-in tooltips. Immediately you will encounter some should-not-occur conditions, and so will have the opportunity to see how gracefully the design adapts. This article concludes with some observations about performance, and ideas for further development of finite state machines for browser-based applications.

40. Finite state machines in JavaScript, Part 1: Design a widget    ibm.com

Finite state machines have long been used as an organizing principle for designing and implementing complex behavior in event-driven programs, such as network adapters and compilers. Now, programmable Web browsers have opened a new event-driven environment to a new generation of applications. Browser-based applications, popularized by Ajax, are becoming more complex. Designers and implementers can benefit from the discipline and structure that finite state machines offer. In this article, you, learn how to use a finite state machine to design complex behavior for a simple Web widget -- an animated tooltip that fades into and out of view.

41. Craft Ajax applications using JSF with CSS and JavaScript, Part 1: Enhance the appearance of your JSF pages    ibm.com

If a Web page has unique styles, you can define style rules within the