Dragging Code

We'll go through the code a piece at a time, like a user would experience it. Then we'll show the entire script.

Listening for Events

The first step is to start looking for events and to ascribe functions to those events. Let's look at Example 15-2, a slice of the complete page.

Example 15-2. Listening for events
						// browser check
browser = navigator.appName
browserNum = parseInt(navigator.appVersion)
N4 = false
N6 = false
IE = false

if ((browser == "Netscape") && (browserNum < 5)) N4 = true
else if ((browser == "Netscape") && (browserNum >= 5))
    N6 = true
else IE = true


function init()
{
    if(N6) { // need to specify objects and call ...

Get Advanced JavaScript™: Insights and Innovative Techniques now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.