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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.