JavaScript Journal

Subscribe to JavaScript Journal: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get JavaScript Journal: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Top Stories

Lately there has been a lot of buzz around HTML5 Web Sockets, which defines a full-duplex communication channel that operates through a single socket over the Web. HTML5 Web Sockets is not just another incremental enhancement to conventional HTTP communications; it represents a colossal advance, especially for real-time, event-driven web applications. HTML5 Web Sockets provides such a dramatic improvement from the old, convoluted "hacks" that are used to simulate a full-duplex connection in a browser that it prompted Google's Ian Hickson - the HTML5 specification lead - to say: "Reducing kilobytes of data to 2 bytes...and reducing latency from 150ms to 50ms is far more than marginal. In fact, these two factors alone are enough to make Web Sockets seriously interesting to Google." Let's look at how HTML5 Web Sockets can offer such an incredibly dramatic reduction of... (more)

Book Excerpt: Introducing HTML5

HTML5 is a draft specification for the next major iteration of HTML. It represents a break from its predecessors, HTML4 and XHTML. Some elements have been removed and it is no longer based on SGML, an older standard for document markup. HTML5 also has more allowances for incorrect syntax than were present in HTML4. It has rules for parsing to allow different browsers to display the same incorrectly formatted document in the same fashion. There are many notable additions to HTML, such as native drawing support and audiovisual elements. In this chapter, we discuss the features added by HTML5 and the associated JavaScript APIs. Beyond Basic HTML HTML (Hypertext Markup Language), invented by Tim Berners-Lee, has come a long way since its inception in 1990. Figure 1-1 shows an abbreviated timeline of HTML from the HTML5Rocks slides (http://slides.html5rocks.com/#slide3)... (more)

JavaScript: The Good Parts

JavaScript is a language with more than its share of bad parts. It went from non-existence to global adoption in an alarmingly short period of time. It never had an interval in the lab when it could be tried out and polished. JavaScript has some extraordinarily good parts. In JavaScript there is a beautiful, highly expressive language that is buried under a steaming pile of good intentions and blunders. The best nature of JavaScript was so effectively hidden that for many years the prevailing opinion of JavaScript was that it was an unsightly, incompetent abomination. This session will expose the goodness in JavaScript, an outstanding dynamic programming language. Within the language is an elegant subset that is vastly superior to the language as a whole, being more reliable, readable and maintainable. Register for AJAXWorld RIA Conference & Expo Submit Your Paper to... (more)

Getting Focus()ed and a Quick JavaScript Lesson

Many new J2EE developers get caught up in focusing on the details and nuances of servlets and JSPs and, as a result, may not learn how to leverage JavaScript. Some may even dismiss it as too much hassle, given cross-browser compatibility issues. For both audiences there's still value in learning at least a minimal amount about client-side scripting. Even learning about just one feature - setting the cursor on the first form field you may have - can bring measurable benefit to your site visitors. In this month's Journeyman J2EE, we depart from pure J2EE topics to address this subject, which should be understood by any Web application developer. If you're a newcomer to JavaScript, I'll provide more than enough to get started. Where's Your Focus? Here's the motivation for the problem I want to solve: you visit a Web site that offers a form inviting you to enter some i... (more)

Using Ext JS, Servlets, JSON, MySQL and Tomcat on Fedora

Java Developer Magazine on Ulitzer These days the popularity of Ext JS (a JavaScript library) is gaining momentum. One of the most popular widgets within Ext JS is the DataGrid. The reason - displaying data from a database is one of the most common tasks of a web application. "Out of the box" the DataGrid has functionality (for instance, ascending or descending sorting and reordering of columns by dragging it) that otherwise would require some effort from developers. Another attractive feature of the DataGrid is that it can use JSON (JavaScript Object Notation), which allows you to reduce traffic in comparison with full Swing HTML or XML formatting on the server. Examples from Ext JS site [1] and Ext JS books such as Learning Ext JS.Packt Publishing [2] are focused on PHP in conjunction with Ext JS. However, what if your organization already uses servlets for web a... (more)

WDDX with JavaScript

This article demonstrates how to use Allaire's XML serialization technique, Web Distributed Data eXchange (WDDX [described at www.wddx.org]), to transfer CFML data structures from the server to the client, and into JavaScript and back. Generally WDDX's approach is to interchange data of all types (including complex data types such as nested structures, n-dimensional arrays, record sets, or even binary data) between different programming platforms. Overview of WDDX WDDX is simply a way of describing data in a text-based form. Technically it's an XML DTD (Document Type Definition) of XML tags that describes simple and complex data types, such as the contents of a nested structure. Many major Web programming platforms are adopting WDDX; it's currently available in CFML, Java, ASP, PHP, and Perl for the server-sided, platform-independent exchange of data. In addition t... (more)

Cloud Expo 2011 New York: Application Development in the Cloud

Cloud Expo 2011 New York $800 Savings here! At Ajax.org they understand that the browser is the future; therefore they have always seen the Open Web as a robust platform for application development. Meanwhile JavaScript is making its grand comeback. Combine these two ideas and you get Cloud9 IDE. Cloud9 IDE hopes to be the IDE for JavaScript developers built by JavaScript developers. JavaScript applications run online for a purpose, so why shouldn't you develop your application online too? In their session at the 8th International Cloud Expo, Lieke Arends, Business Development Manager at Ajax.org, and Rik Arends, Co-Founder and CTO of Ajax.org, will discuss the advantages of developing in the cloud (many of which most developers probably don't know). Explore Cloud Expo Sponsorship & Exhibit Opportunities ! Speaker Bios: Lieke Arends is Business Development Manager ... (more)

Error Handling in JavaScript

Have you ever been to a site and gotten a pop-up box telling you about a JavaScript error on the page? It can be really annoying. What's worse is that the person responsible for maintaining the site doesn't even know that the error occurred. This article isn't about ColdFusion error handling. That was covered in 2000 and 2001 in CFDJ by Charlie Arehart's four-part series, "Toward Better Error Handling," as well as by others. Rather, this article will tell you some ways to trap JavaScript errors on the client. More important, it'll tell you how to communicate these errors to ColdFusion automatically so you can write the errors to a log file or e-mail the errors to yourself and find out about them right away. Indeed, the trick we use may be useful to you in ways beyond just error handling. Error Prevention The primary way to prevent JavaScript errors in your applicatio... (more)

Getting Focused - and a Quick JavaScript Lesson

You visit a Web site that offers a form inviting you to enter some input. No big deal - we see them all the time, right? But do you move your cursor to that first data entry area using the mouse? Or are you, like me, a keyboard maven - in which case you find that often you have to hit the tab key several times before you can enter data? I've visited sites with navigational toolbars across the top and/or left side of the form - forcing me to tab dozens and dozens of times. It's an annoyance, especially if visitors to your site know the site designer could have easily prevented the problem. There's an incredibly simple solution. Just the tiniest bit of JavaScript. A single line of code, really. This article will show you how...and will also lay the most basic foundation of using JavaScript if you're new to it. Laying the Foundation The technique we're talking about here... (more)

JavaScript Now Outstrips Java

JavaScript is the preferred computer language in Europe, the Middle East and Africa, according to a new survey of developers in that region by Evans Data Corp. Over 60 percent of developers use JavaScript and that usage has outstripped all 3GL and scripting language use, including Java. Part of the language’s growth is due to the increased use of AJAX, which is used by 38 percent of developers – a 30 percent increase in the last year, according to EDC. “Web 2.0 is a powerful dynamic that is sweeping the Internet,” said John Andrews, president and CEO of Evans Data Corp. “We’re seeing a lot of excitement about rich Internet apps, mashups, and AJAX in all regions, but especially so in EMEA, and this is spurring the growth in JavaScript use.” The comprehensive survey of 350 professional software developers in EMEA was condu... (more)

JavaScript Execution Context, Closure, Eval and “this” Keyword

These are a few key concepts of JavaScript language that developers should know: execution context, activation object, variable instantiation, scoping, closure, eval and “this” keyword. Knowing these would help one tremendously in Ajax development. For example, when you write an inner function, you know that you can access the local variables defined in the outer function as if they were defined locally. You can also access the global variables. -Why? How does the host environment resolve such variables? Another example: When you pass arguments to a function, you can access these arguments as if they were locally defined variables. How does this work? A slightly more involved example that developers must have seem similar code a lot but may not know the “why”: function outerFunc(outerArg){ var localVar = 100; function innerFunc(innerArg){ localVar+=100; return (oute... (more)