Categories
Just Shelley

New York, New York

It isn’t Fall without trees changing color, birds flying south for the Winter, and being in New York to speak at the Internet World conference — this time as part of the Webmaster Forum.

However, this time, I stayed in New York for a few days. What an adventure.

New York Cabbies

The cab that took me from Penn Station to my hotel was driven by a gentleman from Haiti who happened to have strong religious beliefs. I know he was religious because he kept playing religious tapes, and would slam on the brakes occasionally in order to jot something down in a notebook he kept by his seat. I knew he was Haitian as he would alternate this behavior with Haitian utterances under his breath as he literally tore through that town, determined to get me to my hotel at all due speed.

I didn’t know one could drive between cars in car lanes in New York. I also didn’t know that one could drive 60MPH down Park Avenue in the middle of the day. I do now. I also received a lesson in the finer points of car horn blasting in New York.

There’s the light tatoo on the horn that says “Yo!”. There’s the more emphatic tatooing that seems to say “Yo! Stupid!”.

There’s the single tap that just lets folks know you’re in the vicinity and to watch out. Compare this with the heavy hand on the horn that will get even the most diehard New Yorker’s attention. If the horn blower is a cab driver, people seem to understand that the cabby is just letting someone know that they are invading the driver’s personal territory, whatever that may be.

I also know that pedestrians in New York don’t walk in front of the cabs without looking at the driver’s face, first. How does this driver define territory…

Cab rides are a way to experience New York, but I can’t experience a new town or city from a car — I just don’t like cars. So, I decided to walk to Central Park. On foot. No cabs.

Walking to Central Park

I started my walk on Madison Avenue — established home of advertising agencies everywhere.

Madison Avenue doesn’t have the crowds other streets do in New York, thought there are a large number of gray and black suited people, all with cellphones glued to their ears (call them New York earrings).

The buildings along the way reminded me of some of the canyons I used to explore in Arizona, except those canyons were created by water flows over a millenium of time. New York canyons are built on man’s desire to one up nature. I did notice, though, when I crossed over to Fifth Avenue that the human tide is remarkably similar to a moving river. Woe to you going against that tide of affluent and determined shoppers.

(I particularly treasure a moment when two older, well dressed women walking behind me suddenly stopped in the middle of the sidewalk and murmured “Armani” in one breath. I consider this to be a quintessential New York moment.)

The Park

Central Park is a surpise after all the opulence of the surrounding stores and the shadows cast by the towering buildings elsewhere in downtown New York.

Part of the Park was closed off for renovation, but I walked every last bit of those sections that were open. And it was a long walk.

First, let me state categorically that I cannot BELIEVE that anyone would jog in the Park after dark. The place is full of nooks and crannies, dark corners, and bushes. Charming by day, sinister by night. A horse carriage ride, yes — but not a lonely stroll through the footpaths. I’d rather play tag with a grizzley. It would be safer.

Central Park is pretty, but the trees look a little tired, and more than a bit dusty. However, the bushes and lawns are very pretty, as are the little specialized areas such as the Dairy farm.

I found an old fashioned carousel and thought about taking a ride, but dignity intruded — dammit.

My favorite sections of the Park were rocky outcroppings with bits of mica scattered about, sparkling in the noon day sun. Something like the windows at Tiffany’s and Cartier’s I passed on the way, only I could touch the rocks at Central Park and not get arrested.

I actually saw a black squirrel; I’ve not seen one of that coloration before. I don’t have my books to check to see if this is a natural variation, or a protective adaption based on New York city smog. (I know, meow, meow — but Boston is a whole lot greener.)

I walked through some bushes at one point and found a group of people silently standing around a mosaic embedded in the cement. All the mosaic had on it was the single word “imagine” — I was in Strawberry Fields, the John Lennon memorial.

One word, and I stopped dead in my tracks. One moment, with a lifetime of memories, flooding in, all because of that one word.

Back from the Park

I was getting tired at this point, so back to the hotel.

Towards the end of my walk, I stood out in front of St. Patrick’s Cathedral, an incredible edifice of which New Yorkers take considerable pride. If you’ve been to New York, you know what it’s like to come upon the Cathedral after blocks and blocks of modern glass and steel.

I have to admit that when I first looked at St. Patrick’s, I thought of how much further we would be as a people if only we expended as much energy and resources on education as we did and still do on religion.

We could have cured cancer by now, eliminated all smog and pollution, perhaps be walking on some distant planet around some distant sun.

Then I walked into St. Patrick’s. I literally stopped in the middle of the Vestibule, overwhelmed by the absolute rightness of the interior of the church. The vaulted ceilings, the stained glass windows, the slight smoky air from thousands of votive candles lit by the faithful.

It then came to me that without faith — or perhaps human spirit — we wouldn’t even try to cure cancer, or walk on the moon, much less planets surrounding distant stars. And we wouldn’t have beauty such as that.

Maybe we didn’t do so bad with our time and our resources in the past, after all.

New York, New York

My last stop on my walk was Rockerfeller Center, located a couple of blocks from the hotel. As I approached the Center, I could hear the strains of the Sinatra song, “New York, New York” filling the air. I kid you not — there had just been an ice show at the center, which finished by playing New York’s anthem song.

I couldn’t end my walking tour of New York on a better note than that.

Categories
Just Shelley

Every Person’s Math

Ask folks what class they feared the most in high school and college, and I bet you’ll find that “math”, generally, or “calculus”, specifically, is the answer you’ll get more often than any other. Yet math is really nothing more than a) the ability to apply specific equations and get consistent results, and then b) to apply those results to better understand the world around us. So, I think its time to take a look through the Internet and see what we can learn…about math.

Basic Math: If a train left New York and another left Boston…

Most of us know basic math. It’s the math we use when we shop: we pick up half a dozen eggs, we buy 4 steaks, we supply cash for totals and get change back. Its also the math we use at home: we measure out 1 cup of flour, we shape dough into a circle to make a pie, we time how long the pie has baked, and we cut a board in such a way that it fits into a slot on the floor. How about at work, do we use this math at work? You bet: we ask for two packets of sugar for our coffee, the delivery person drops off a gross of pens, we send mail using two day express delivery and know that the mail will be delivered in two days or less.

Basic math is that math that surrounds us and that we use in our everyday world. It is the math that allows us to time events by understanding units of measurement about time, such as hours, minutes, and seconds. It is the same math that then gives us the tools to measure these units and express this measurement as a factor of time elapsed: he ran the marathon in 6 hours, 23 minutes, 3 seconds.

Additionally, basic math is that math we use when quantifying objects, such as 2 apples, 3 people, 4 cats. It is also the math we use with currency and with temperature — though units of measurement can differ here — and with our payroll stubs and income tax.

Basic math consists of addition and subtraction, multiplication, and division, and we can’t forget the most infamous of them all: fractions. It is arithmetic.

Basic math is the math we learn first, and the one that requires us to learn the most and take the largest leap of faith. After all, in algebra we may understand that 2x – y = 3 is a solvable equation, but it is really based on our belief that the number “2” does represent two objects; that two numbers can be multiplied and the result will always be the same; that you can add two numbers and consistently get a third; and that you can then subtract one of the original numbers from the new total, and derive the other original number.

3 + 4 = 7

what will you get if you take 4 away from 7?

Look at that! Your first number quiz.

 

So, did you get the correct answer? If you’re not sure, you might want to ask Dr. Math to help you find the answer . How about a different way of learning math? You might want to check out The Clock (Modular) Arithmetic Page for a little learning about math, in the round. Want to have a little fun with math? Then check out the Math Forum Elementary Problem of the week — see if you can keep up with the kids.

Of course, once we learned basic math, it was time to get into other types of math such as algebra, covered next.

Algebra and the ultimate question: Why?

So what is algebra and why do we need to learn it? Well, something like arithmetic is good when dealing with math of known quantities and objects such as adding two apples together, or measuring a cup of flour. But what if you need to solve an equation involving the addition of 2 quantities of an object, and you only have one of the quantities and the result?

Remember our little math game in the last section:

3 + 4 = 7

what will you get if you take 4 away from 7?

 

Well, let’s rephrase this question and formalize it into an equation. Instead of saying “if you take 4 away from 7”, say “if you take a number away from 7 you’ll get 4”, and rephrase it again to say “if you add a number to x, you’ll get 7”. Drawing this as an equation, you get:

x + 4 = 7

Algebra is involved with solving the equation for the unknown variable, in this case, x, using a set of rules and procedures to accomplish the task.

For our equation, we first need to isolate the variable, or the unknown value. We can do this by using basic math to eliminate the known value from both sides of the equation:

x + 4 - 4 = 7 - 4

x = 3

Isolating the unknown is the same as solving for the unknown.

See, you just did algebra! That wasn’t so bad, was it?

To summarize, algebra is the ability to solve equations containing one or more unknown variables. The solution is found by applying known procedures such as isolating the unknown variable and combining like terms. Algebra then uses these same rules for more complex equations such as finding ratios, multiplying fractions, graphing results on a coordinate plane, and exponents. Before you click away again, let’s look at each of these and see that there is nothing scary or weird with any of them.

First if all, you use ratios anytime you figure out your odds of winning the lottery (1 in a kagillion), or you read about something such as the “ratio” of women to men of those responding to a survey, for instance, the ratio was 3:5, or 3 women out of 5 respondents were women. If we look at this as an equation, we would have:

x + 3 = 5

x + 3 - 3 = 5 - 3

x = 2

there are 2 men for every 5 respondents

How about graphing? Well, I used to love to graph. I loved the graph sheets, I loved getting my ruler and my pencil and drawing out a nice clean line. Didn’t have a clue why I was doing it, but it sure was fun.

You know graphing: on a number line graph all numbers less than 8. You end up with:

Now, what is there about this that isn’t fun?

Of course, once we mastered graphing on a linear line, the next step is to try graphing within a coordinate system. This is a graph where the X values are plotted along a horizontal line and the Y values are plotted along a vertical line. The Y-axis intersects the X-axis at the point where X is zero, and the X-axis intersects the Y-axis at Y’s 0 point. Then, individual points on the graph are plotted at the point where the X value and Y values intersect. So, if you have an X value of 3 and a Y value of 3, your point will exist in the upper right of the system. If you have many points, such as those drawn for an equation and using different values of X or Y in the equation, you can connect the points and you actually have a line. From this you can determine not only what values are from an equation for given values of X or Y, you can determine what all values of X or Y will be. Why? It’s in the graph!

So, we know that basic arithmetic isn’t scary, and algebra can be fun, are you ready to try something a little stronger? Say, Geometry?

If you want to know about algebra, have I got some sites for you. First up is Math for Morons Like Us. Don’t let the name chase you away, this really is an impressive site providing an overview of pre-algebra, algebra, geometry, and calculus. Math for Morons was created for the ThinkQuest program. ThinkQuest is a competition held every year where students or adults who are teachers or studying to be teachers can create Web sites, all based on knowledge and education. There some pretty impressive Web sites from this project. For instance, another Web Site is Volcanoes Online, created by students from all over the World.

Now, doesn’t all this sound like fun? Well, to make it even more fun, James Brennan from Boise State University has created an interactive Java applet called the Graph Applet. Try it out.

Geometry

Well, you’re probably pretty comfortable with addition and subtraction and even equations, about now. Time to up the ante and take a look at geometry.

First of all, to ease your anxiety, and to keep you from clicking out of the page, geometry is not only fun, it is really based on the same mathematical foundation you worked with in the basic math and algebra sections. Now, those sections weren’t so bad, and this one doesn’t need to be either.

So, what is geometry? Well, it has to do with shapes. All kinds of shapes, from lines to circles to triangles to spheres to what have you. Geometry gives you the tools to do such things as find the volume of a sphere or to find the circumference of a circle.

You don’t think you need this kind of stuff? Well, sure you do.

For instance my husband and I walk around a water reservoir behind our place that has a diameter of about .4 miles. We were curious about the actual distance we traveled so we dusted off our geometry and found the formula for finding a circumference of a circle given the circle’s radius:

   C = 2(PI)r

Well, a diameter of a circle is twice the size of the radius, so the radius of the lake would be .2 miles. Plugging this in for r, and remembering that the value of PI is 3.14159 — five decimal places is more than enough, we ain’t building a rocket here – we would have:

  C = 2(PI)r
  C = 2(PI).2
  
  C = 2 x 3.14159 x .2
  C = 1.25663

Hey, 1.25 miles! A nice little jaunt.

Geometry is very big in the computer animation business. Did you like A Bug’s Life or Antz? Well, geometry is a basic tool used in creating these types of animations. Geometry also forms the basis for work accomplished with VRML — Virtual Reality Modeling Language.

If you like Geometry, then you might want to look more closely at trigonometry, covered next.

Where to begin when it comes to learning about Geometry. You can go back to Math for Morons Like Us, which has excellent coverage of Geometry in addition to Algebra. You can also go to the Geometry Home Page, which has some very nice tutorials. There’s also the Geometry Center, with documents, multimedia, and software about geometry. This site led me to another site, called Science U, which has its own Geometry Center. Science U has several interactive demos and games, related to geometry and astronomy. Site also has an online store with some unusual items for sale. There aren’t many places where you can create your own fractal design and then have it made into a T-shirt.

Wait, there’s even more sites. I mentioned the use of geometry with computer animation and VRML. Only fair to mention some sites for these topics. First of all, the grandmother of VRML sites is The VRML Repository. Two other essential links are VRML Consortium, and The VRML Specification. And you can’t mention VRML without reference to the SGI VRML page.

For computer animation, try out The Shape Modeling and Computer Graphics page, from the University of Aizu in Japan. Webreference, a favorite of mine, has a nice site called the 3D Animation Workshop. And the king of computer animation is, of course, Pixar.

Oh, and don’t forget the Antz and A Bug’s Life official Web pages.

Trigonometry

Okay, you had some fun looking at all the pretty computer generated animations and graphics. Let’s get back to the real reason you’re here: to learn more about math. Right?

First, trigonometry — or “trig” as it is affectionately known — is based on angles. It is this, which distinguishes trig from the rest of geometry.

Why learn more about trig? Well, if you are interested in astronomy, you should be aware that it is trig, and the trigonometric tables, that provided the basis for early star charting. Engineering is dependent on trigonometry. When you see surveyors along the road at construction sites, what do you think they are using to plan the work? Why, trigonometry, of course.

Consider a building. Can you measure how tall it is? You could climb to the top of the building and drop a line of rope down from the roof until it touches the ground and then you could measure the rope. However, this doesn’t sound like a very efficient method, and what if you are trying to measure a mountain peek, or a balloon in the air?

A better approach would be to use our friend, the right triangle, and the trigonometric functions.

First, a right triangle is one which has one 90o angle. The angle opposite the right triangle, along the horizontal axis is written as q, and is called theta. The side of the triangle opposite and adjacent to q are known as, respectively, the opposite and adjacent sides. The side opposite the right angle is known as the hypotenuse, as shown in the figure below.

The trigonometric functions, based on the graphic, are:

  • sin q = opposite / hypotenuse
  • cos q = adjacent / hypotenuse
  • tan q = opposite / adjacent
  • csc q = hypotenuse / opposite
  • sec q = hypotenuse / adjacent
  • cot q = adjacent / opposite

Now, considering the right angle and the trigonometric functions, how can we measure that building? Well, you start with a protractor, a small plastic semi-circular or circular disk that allows you to measure angles. You walk 100 feet from the building and then measure the angle from yourself to the top of the building using the protractor. Let’s say this angle is 60o.

At this time you have some known values. You know that q is 60o, and you know that the adjacent side is 100 feet. Now, to get the value for the opposite side, we’ll use the trigonometric formula to compute the tan or tangent of the angle:

tan q = opposite / adjacent

tan 60o = opposite / 100 feet

tan 60o = 1.73

1.73 * 100 feet = opposite / 100 feet * 100 feet

opposite = 173 feet (approximately)

There you go, you found the height of the building all by yourself, with a cheap plastic tool and no long rope. Pretty darn good — and all thanks to trig.

Well, now that you have found that trig is fun, time for pulling in the big guns. Time for calculus.

I just can’t believe how many Web sites there are on math, including trig. First of all, check out the Free-ed Net, specifically the section on Trigonometry. Free-ed Net is a very hot Web site focusing on free educational resources on the Net, and in the Trig section, they list some nice trig resources. First of all is S.O.S. Mathematics, which provides an overview of Trig, and provides a table of trigonometric identities. Then there is the Math Abundance Trigonometry Introduction, which is very extensive. Very.

Sorry, I’m back. I was sidetracked by Net-Ed’s Astronomy section. Where was I? Oh, yes, trig resources. A great trig resource page is at Study Web’s Math page. I can guarantee that if you go through all the resources they list, you will be a math wiz. Angles, are your friends.

Do you want to order a protractor of your very own? Then check out k-12source.com which has most school supplies for sale. Check out the engineering and drafting supplies.

Oh, and if you want to know how to measure the height of a rocket, check out the University of Nebraska page on measuring a rocket’s height, from the N.E.R.D.S (Nebraska Educators Really Doing Science) project.

Bring on the tanks: Calculus

Well, you’ve made it this far so you deserve a real treat: Calculus!

What is calculus about? Well, first of all it takes what you know with the other math types, and goes a bit farther, or nearer as the case may be. The Excite online encyclopedia, InfoPlease has the following definition for calculus:

"branch of mathematics that studies continuously changing quantities. 
The calculus is characterized by the use of infinite processes, involving passage 
to a limit the notion of tending toward, or approaching, an ultimate value. 
The English physicist Isaac Newton and the German mathematician G. W. Leibniz, 
working independently, developed the calculus during the 17th cent. The calculus 
and its basic tools of differentiation and integration serve as the foundation 
for the larger branch of mathematics known as analysis. The methods of calculus 
are essential to modern physics and to most other branches of modern science and
 engineering."

Calculus isn’t just one subject, it’s many. There is differential calculus, integral calculus, there is statistics, and probability, and so on. However, it is also about the world around us. It is not an exercise in seeing how many equations one can stuff into a sophmore’s brain before it explodes.

For instance, could you see needing to know the volume of a sphere? Sure you could. How does one measure the volume of a sphere?

Well, going with empirical method, you could fill the sphere with water and measure how many cups of water fit into the sphere. But, this technique is kind of wet, possibly messy, perhaps not very scientific, or even accurate. Wouldn’t you really rather use a formula?

Borrowing from integral calculus, the formula for calculating the volume of a sphere is:

V = 4(PI)r3/3

So, given the sphere’s radius, you can now find its volume. You can find its surface, too, with the following formula:

S = 4(PI)r2

I won’t lie to you and say that all calculus is this easy. I still think parts of calculus are a joke perpetuated by math majors on the rest of us (“let’s string them along…see when they break”), but calculus can be met face to face at the least, and even mastered (gasp) at the most.

Now, I think that’s enough for me to say on calculus. I’ve forgotten way too much on this subject and if I say anthing more, I’ll embarrass myself. Time to follow this article’s links … and learn a little math.

Well, I have to go back to Math for Morons like us for their coverage of pre-calc and calculus. Boy, I wish they would change the name. But they aren’t alone with the names, as another good site on Calculus is Help with Calculus for Idiots (like me).

The best reference page with listings on calculus is StudyWeb’s Calculus page. Another great resource on Calculus is Calculus Net.

An example of calculus applied to mechanics is nicely illustrated at Calculus and its Applications to Mechanics. A fun site is a page full of Calculus Java applets where you can change values and observe results for calculus equations.

You can calculate the volume of most shapes with the ABE Volume Calculator page. You can find the calculations used at Calculations for Volume.

Flame on.

Categories
Just Shelley

Working at Home

Imagine this scenario: You get up in the morning, grab a cup of coffee, and wander out to the Living Room. You stand and gaze out the window for a few minutes taking advantage of that great mountain view. Then you casually go into your home office and start looking through your email. After you handle your email you take a shower and get dressed, sweats or jeans or shorts maybe, and you go back to your office and get down to some serious work. You break when you are tired and you eat when you are hungry. When the kids come home from school you chat with them about the day and maybe you even go for a walk with them. Later you get back on the computer for another few hours and quit for the night, satisfied with your day’s work.

Okay, everyone, you can stop crying now. And you can stop shaking your head,  saying this is impossible. With today’s technology, this is not only possible it is becoming cost effective and practical.

Today many of us have access to computers in our homes that enable us to do anything from creating a report, researching a product, to writing complex computer software. With the increased proliferation of ISDN lines and alternative connectivities being explored, we can connect with our jobs and have virtually the same access as we would sitting at a desk on site. And that office does not have to be in the same town.

Security? This does not have to be a limitation. We are learning more about computer security than ever and we are finding more ways to increase the safety of our systems.

Cost? How much does it cost you to maintain a workable environment for each of your people? If you are maintaining a site for a software developer you are maintaining software, a machine, a phone line, restrooms, an ergonomically designed workstation, and you are maintaining a location. That last one is a real key. Companies are growing and are finding that they may actually be running out of room to house their people, so they double up and cram people in and they lose productivity and they may actually lose people.

Teamwork? Have you had a chance to try out Netscape’s new version 3.0 beta software with LiveChat. I went out and talked and shared a virtual whiteboard with some person in Utah, and someone else in Texas. And this is a freebie add-on to an internet tool. You have the technology now to have cameras mounted on PCs and have people share virtual working spaces and work cooperatively online. The only thing you don’t share is bad breath.

Benefits? I bet if you promised this capability to people on only a partial week basis you will have increased worker satisfaction and a whole lot more people wanting to work for you. How about having to maintain less desk space if you have workers desk share? How about having fewer cars in your parking lot, which is probably overcrowded as it is. How about giving back to the community by fewer cars being on the road?

Sick Time? If you have an employee with a broken leg they can work at home. If they have a bad cold? The employee probably would come into work, be pretty uncomfortable and manage to pass their germs to half a dozen other people. Wouldn’t you rather they stay home? How about maternity or paternity leave? Nice option for those folks who would like to be available to their kids and still have a career. What a concept!

So, why is this not happening more? Some types of work just won’t make the transition to at home work such as factory and manufacturing processes and many services and other professions. If you have a home cleaning service, this usually means the customer’s home. And some companies are not set up yet, and may not be able to afford the type of setup that would enable their employees to work from home. Other companies may work on super secret stuff that has to be worked on behind armed guards and locked doors.

Now let’s look at the ‘bad’ reasons for not allowing people to work at home.

You don’t trust your employees and you have to have your eye on them at all times. Go Away. You have hired professionals and adults, consider treating them as such and you probably will not have the turnover you now have.

The work you do needs a centralized database. With the increased ISDN line connectivity, you can connect to your database efficiently from home. How about taking snapshots of the database to work on from your home PC? Concerned about someone accessing company secrets from this? Ask yourself this: Do you think that your secret is important enough that a person will break into your employee’s home to access their PC? Do you have armed guards at your front doors to keep people from walking in? Do you have absolutely no connection between your internal computer system and an outside connection? If you answered No to any of these, try a different mindset.

A legitimate concern is the availability of people for mentoring, or for brainstorming, or for any other cooperative task. You might want to consider how much of this really does occur and you then might want to consider a partial solution such as desk sharing: two people share a desk and a PC and work at home part of the week and at work part of the week.

Communication? Last I heard, homes had phones too, and email and internet connectivity…

Concerned about that security issue? Check with consultants in your area and find out the security risks. Don’t just assume that this type of connectivity will take your important systems down, find out the facts.

How about liability? Concerned that your employee may get hurt at home and sue you? Check with your lawyer and also your insurance companies about steps you and your employee can take. And lawyers and insurance companies, start understanding this type of business…it will only increase in the future.

Costs? You bet there will be costs to enabling off-site employees if they need computer access. But consider what you can get back: The main factor that raises envy in me and my professional peers is when one of us can work at home. It even beats out salary as the number one reason to take one job over another. And for most companies, the number one cost is their employees. Want to attract and keep the best?

There are a lot of issues to working at home. I would like to hear from companies that have made this transition successfully and would like to publish your success stories in the month’s to come. And I would also like to hear from those companies who have made a choice not to allow off-site employees and their reasons. Let’s start exploring this issue and see “Why we CAN work at home”.

That’s it, folks.

Categories
Just Shelley

Netscape Navigator’s JavaScript 1.1 vs Microsoft Internet Explorer’s JScript

Originally published in Netscape World, archived at the Wayback Machine

Prior to Netscape implementing JavaScript in Netscape Navigator, web developers had few tools to create interactive content for their web pages. Now this scripting language gives developers the ability to do things such as check form contents, communicate with the user based on their actions, and modify the web page dynamically without the web page being re-loaded and without the use of Java, plug-ins or ActiveX controls.

Unfortunately, JavaScript was not usable by any other browser until Microsoft released Internet Explorer (IE) 3.0. With this release web developers could deliver interactive content that would at least work with the two most widely used browsers. Or could they?

On the surface, the JavaScript supported by both companies is identical. They both provide the same conditional control statements, have defined objects such as window or document,and can be used directly in HTML documents. They both support events based on user actions and support functions in a similar manner. However, this article will demonstrate that though the languages may look the same on the surface, there are differences that can trip the unwary developer.

JavaScript Objects

To understand the differences between the two implementations of JavaScript you must examine the objects both support. As an example, with Navigator 3.0 Netscape provides a new object image which is an array (defined as images that contains the images in the document currently loaded. This object allows the developer to change the images of a document without re-loading the document or using Java or other technique. With this capability the developer can write the following JavaScript code section without error:


sSelected = "http://www.some.com/some.gif"
document.images[iIndex].src = sSelected

This code will change the src property of the image that is contained in the array at the index given in the variable iIndex. If this variable contained the value 2, the 3rd image as loaded in the document (the array indices begin at 0) would be changed to the image located in the given URL. An example using images can be found here.

Running the same example with Internet Explorer will result in a alert message that states that “‘images’ is not an object”.

Other examples of objects that are defined for Netscape Navigator but not for Microsoft Internet Explorer are:

  • The Area object, which is an array of links for an image map that allows the developer to capture certain events for the image map that can be used to provide additional information to the user. With this, the developer can capture a mouseOver event to write out information about the link in the status bar.
  • The FileUpload object which provides a text like control and a button marked with “Browse” that will allow a reader to enter a file name. The JavaScript can then access the name of the file.
  • The Function object which allows the developer to define and assign a function to a variable which can then be assigned to an event.
  • The mimeTypes Array of supported MIME types.
  • The option object which is an array of the options implemented for SELECT and which allows the developer to change the text of the option at runtime
  • The applet object, which is an array of Applets in the document (read-only)
  • The plugin object, which is an array called embeds that contains the plug-ins contained in the document (read-only)
  • The plugins array, which is an array of plug-ins currently installed in the client browser

At this time there are no JavaScript or JScript objects defined for Internet Explorer that are also not defined for Netscape. However, as JScript is an implementation script for IE and Microsoft has defined their own IE scripting model, this could change in the future.

JavaScript Object Behavior and Ownership

Internet Explorer may not have additional objects but it has defined a different hierarchy and ownership for some of the objects that are used by both it and Navigator. All objects are contained within the window object in the IE scripting model, which can be viewed here, but not all objects are owned by window with the Navigator model, which can be viewed with the JavaScript Authoring Guide. The object Navigator, which is the object that stores information about the browser currently being used, is an example of an owned object by window in IE but not in Navigator.

This will not present an incompatibility problem between the two browsers as the developer will usually not preface the object with the term “window” as the following code demonstrates:


<FORM NAME="form1">
<input type=button value='press' onClick="alert(navigator.appName)">
</FORM>

The above code will work with both browsers.

The differences between the ownership can become a problem when an object is owned by different levels of objects. An example is the history object, which is owned by the windowobject in IE, but by the document object in Navigator. When used in the current window and document, the object will work the same as the following code will demonstrate:


<FORM NAME="form1">
<input type=button value='press' onClick="history.back()">
</FORM>

The reason the same code can work for both is that window is assumed for both IE and Netscape and document is assumed for Navigator, at least in this instance because history is also an object in its own right. In the case of a document being opened as part of a frame, the differences then become noticeable. The following code will work when the document is opened as a frame in IE, but will not work in Navigator:


<body>
<script>
function clicked() {
history.back()
}
</script>
<FORM NAME="form1">
<input type=button value='press' onClick="clicked()">
</FORM>
</body>

Clicking on the button from the code above will work for IE. The previous document in the History list will be opened, but the same code will not work for Navigator. Clicking on the button will result in neither a change of document nor an error. Prefacing the history object with parent will enable this code to work with both browsers.

JavaScript Properties

Even when IE and Navigator share a common object and a common object ownership, they can differ on the properties for an object. An example is the document object. The properties for both implementations are the same except for an URL property for the Navigator implementation and a location property for the IE implementation. However, if you examine both properties, they are identical! Both contain the URL of the document. Both are read-only. The following code will work with Navigator, but results in an empty Alert message box for IE:


<FORM NAME="form1">
<input type=button value='press' onClick="alert(document.URL)">
</FORM>

According to Microsoft documentation, the equivalent for IE would be to use document.location.href. However, though this does not result in an error, it also results in an empty alert box. The following code achieves the desired results and, happily, works in both browsers:


<FORM NAME="form1">
<input type=button value='press' onClick="alert(location.href)">
</FORM>

The above example does demonstrate another area of caution when using the JavaScript language: this language is unstable in both environments and is changing continuously. Don’t assume something will work because the documentation states it will, and don’t assume it will work the same on all operating systems. Both browsers can have different behaviors across different operating systems, sometimes because of operating system differences and sometimes because of bugs that were missed during testing on that specific OS.

JavaScript Methods and Events

A web developer can find ways of working around differences in objects and properties, but working around differences in methods may not be so easy. When we develop we expect a certain behavior to result when we call a specific function and pass to it certain parameters. With Microsoft Internet Explorer and Netscape Navigator, the best case scenario is that we can use a pre-defined object method with both browsers and have the same result. The worst case scenario is that the method works with both browsers, but the result is different.

An example of the best case scenario is to use JavaScript to validate form field contents which have changed or to use these contents to calculate a value used elsewhere. Calling a JavaScript function from the onChange event to process the changed contents as demonstrated below will work with both browsers:


<!--- Form fields
<p>Item Quantity: <INPUT TYPE="text" Name="qty">
Item Cost: <INPUT TYPE="text" Name="cost"
                onChange="NewCost()">
Total Cost: <INPUT TYPE="text" Name="total" Value=0>
…
<!--- Function
<SCRIPT LANGUAGE="javascript">
<!--- hide script from old browsers

// NewCost will
// calculate cost of qty and item
function NewCost() {
        var iCost = parseFloat(document.Item.cost.value)
        var iQty = parseInt(document.Item.qty.value)

        var iTotal = iCost * iQty
        document.Item.total.value = iTotal
        }

The above will work as expected with both IE and Navigator. When the user enters a quantity and a cost, the onChange event will fire for the cost field and a JavaScript function called NewCost() will be called. This function will call two built-in JavaScript functions, parseFloat() and parseInt(), to access and convert the form field values. These will then be used to compute a total which is placed in the total field.

So far so good. Another JavaScript function in the web page will be processed when the user presses the submit button. This pre-defined button style will normally submit the form. The developer can capture the submission and perform validation on the fields. Coding this for Navigator would look like the following:


<FORM NAME="Item"
        ACTION="some.cgi" onSubmit="return SendOrder()">
…
<!--- Function
// submit order
function SendOrder() {

        // validate data
        if (document.Item.Name.value == "") {
                alert("You must enter your name")
                return false
                }
        return true
        }

Capturing the onSubmit event will allow the developer to call a function to process the form fields. If they choose, they can perform validation in this function. If the validation fails, say the user did not provide a name, the function notifies the reader and returns false, preventing the form from being submitted. If the user did provide a name, the function would return true, and the form would be submitted.

Following the documentation that can be found at the Microsoft site, the developer would expect something like this to work for IE as well as Navigator. It does, to a point.

With IE the onSubmit event is captured and the SendOrder() function is called. If the user did not enter a name value, an alert would occur. The behavior is the same for both browsers at this point. However, if the user does provide a value, Navigator would then submit the form and a follow-up form would be displayed. This does NOT occur with IE IF you are testing the page locally, probably due to a bug missed during the testing. It does work if you run the web page documents through a web server.

However, without knowing that the difference between the two results was a matter of document location rather than document coding the web page developer could have spent considerable time trying to get the same behavior for both browsers.

Aside from the differences already noted, the browsers may process code in a funtionally identical manner and yet perform quite differently. This can be demonstrated with another popular use of JavaScript which is to open a secondary window for some purpose and to maintain communication between the two windows. This is widely used by Netscape for their tutorials.

Both browsers support a property for the window object called opener. This property can be used to contain a reference to the window that opened the secondary window.

The following code demonstrates using JavaScript to open a secondary window and to set the opener property to the original window:


<HTML>
<HEAD><TITLE> Original Window </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--- hide script from old browsers
// OpenSecondary will open a second window
//
function OpenSecond(iType, sMessage) {
        // open window
        newWindow=window.open("second.htm","",
                "toolbar=no,directories=no,width=500,height=300")
        // modify the new windows opener value to
        // point to this window
        if (newWindow != null && newWindow.opener == null)
                newWindow.opener=window

        }
// end hiding from old browsers -->
</SCRIPT>
</HEAD>
<BODY>
<H1> Open a new Window and get information</H1>

<FORM NAME="CallWindow">
<p>Click to open Window:
<p>
<INPUT TYPE="button" NAME="OpenWin" VALUE="Click Here"
        onClick="OpenSecond()">
<p>
</FORM>
</BODY>
</HTML>

The above HTML and JavaScript creates a simple document with one button. Pressing the button opens a new window (creates a new instance of the browser) that does not have a toolbar or directories and is set to a certain width and height. The HTML source document that is opened into this new window is “second.htm”.

The HTML and JavaScript in the secondary window is shown below:


<HTML>
<HEAD><TITLE> Information</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!--- hide script from old browsers
// SetInformation
// function will get input values
// and set to calling window
function SetInformation() {
        opener.document.open()
        opener.document.write("<BODY>")
        opener.document.write("<H1> Return from Secondary</h1>")
        opener.document.write("</BODY>")
        opener.document.close()
        opener.document.bgColor="#ff0000"
        window.close()
        }
// end hiding from old browsers -->
</SCRIPT>
</HEAD>
<BODY>
<p><form>
Click on the button:<p>
<INPUT type="button" Value="Click on Me"
     onClick="SetInformation()">
</CENTER>
</FORM>
</BODY>
</HTML>

This code will display a button labeled “Click on Me”. Pressing this button will result in the document page for the original window being modified to display the words “Return from Secondary”. The JavaScript will also change the background color of the original document and then will close the secondary window. When run in Navigator, the sample behaves as expected. Not so, however, with IE.

First, when you open the secondary window in IE you will notice that the document in the original window seems to blank out for a moment. In addition, the secondary window opens at the top left hand side of the desktop with IE but opens directly over the original window with Navigator, no matter where that original window is.

When you press the button that modifies the original document, IE does modify the document with the new header, as Navigator does, and the background on the original document will change briefly. However, when the secondary window is closed the background color of the original document returns to the original color!

What is worse is that running this sample for a few times with IE will cause the browser to crash! How soon it will crash seems to suggest that resources are not being freed, or are being freed incorrectly. Whatever the cause, this behavior should make a developer feel cautious about opening up a secondary window within IE.

Solutions to working with both Internet Explorer and Navigator

JavaScript is a useful tool for creating interactive content without using Java or some other technique. As we have seen, problems arise out of the incompatibility between Navigator and IE. What are ways to avoid these problems?

  • Code for one browser only. This is not really a viable solution. While Netscape Navigator is the most popular browser in use today, Microsoft Internet Explorer is gaining quite a following. Using Navigator-only JavaScript that will limit your web page’s audience.
  • Code only to the least common denominator. By limiting the JavaScript to that which works for both Navigator and IE, developers will have access to most of the functionality they need. However, with this approach developers will need to be aware of the gotchas that have been discussed in this article. In other words, the developer has to test with both browsers; the tests will have to occur via the web server as well as run locally; the tests should be repeated several times to ensure that no adverse effects show up over time; the code should be tested with all possible environments.
  • Code for each browser within the same page. This is actually my favorite approach though it will require more effort by the developer. Both browsers will process JavaScript labeled as <SCRIPT LANGUAGE=”javascript”>, however only Navigator will process script labeled as <SCRIPT LANGUAGE=”javascript1.1″>. With this approach, the developer can place JavaScript common to both browsers in a SCRIPT tag labeled with “javascript” and Navigator specific code in a SCRIPT tag labeled with “javascript1.1”. To add in IE specific code, the developer would probably want to use VBScript code or use the tag JScript whenever applicable. At this time, JScript is implemented for scripting with events only, not as a language specification for the SCRIPT tag.

Summary

JavaScript is a very effective tool, and a relatively simple method for adding interactive content to a web page. With version 3.0 of Internet Explorer, using JavaScript is viable for both of the most popular browsers in use. However, developersneeds to be aware of the differences between Netscape Navigator and Microsoft Internet Explorer and should test thoroughly with both before posting the page to their site.