Javascript Woes

I ran into an interesting problem today. A form I was filling out was using javascript to validate form variables, usually not a big deal. But this one managed to crash firefox. Definitely not your run of the mill Javascript code.

Peaking into the source quickly pinpointed the error. On the form input validation was performed with the onBlur event handler. If the value entered was not a number this is what followed.

  1. focus was restored to the input
  2. An alert instructing you to enter a number was displayed

The problem existed because of the ordering of those two statements.

What actually happened was

  1. focus was restored to the input
  2. An alert instructing you to enter a number was displayed
  3. the focus left the input and the onBlur event kicked in as you dealt with the alert
  4. because you had not been able to correct the value step 1 was called again

Switching the order, at least doesn’t crash browsers, but it still doesn’t work quite right. In the past I have attached a number validation routine to the onKeyUp event. Using a loop, cycle through the characters in the value in Question, if NAN then set the value to the substring comprised of the leftmost (length-1) characters. This still isn’t perfect because you can defeat it by inserting non numeric characters in the midst of the string. The other problem is that it gives the user no indication ( aside from changing the value) that an inappropriate value has ben entered. If they aren’t paying attention they will just keep typing away.

Posted by Chris Clark Tue, 23 Mar 2004 02:54:00 GMT


Site Monitoring

I have been using Internetseer to monitor my server, and verify that it is online. I haven’t had any complaints with them, though as a free service I receive a few pieces of mail occasionally.

Today, I received a notification that my server was down, just after we left the house. Already running late, I decided to just skip it and see if it was just a minor glitch. A few minutes later I received an alert to my phone, something coming from yahoo. At this point I started waiting for the second message from Internetseer, as yahoo sends my alerts to an email account set up on my server, that I then forward to my phone. This way I can give someone an email address that will always get to me, as text, but not give them the ability to call me.

Nothing came in from Internetseer for a few hours, and when it did come in, it was a notification that my server was still down. Problem with this time was that I was actively connected to the server at that time. Checking my mail, and using the webserver to post a comment to this blog. I am still waiting for the all clear, and have been using the server for 45 minutes.

I guess they still have a few bugs to work out.

Posted by Chris Clark Sat, 31 Jan 2004 03:14:00 GMT


Error Handling

This was going to be a post about the KState womens basketball game(they won against Baylor 85-65). But instead I first started to catch up on my reading, while the kids fell asleep.

While reading Dunstan’s blog I came accross an error. Across the top of the content was the description of the sql error. Directly below that was Dunstans acknowledgement that his site had an error. I like sites that are able to admit that something occasionally goes wrong, I can’t stand the default behavior of IE/win. Whoever made those Friendly error messages was not thinking. They tell you nothing usable at all, and frequently what little they do tell you is wrong.

When making a web application, I believe it is very important to add in error handling of the sort Dunstan is using. Email yourself everytime an error occurs, include all the information you can possibly collect about the error. Don’t rely on the user to give you the details. They usually don’t know what they did to cause the error in the first place, and when they do, they tend not to remember the exact wording of the err message. (I caused about six errors on Dunstans site, and even though all but the first one was on purpose, I was interested in how he handled the error, I still couldn’t tell you the wording of the errors. It is not my job as a user to know that.) At work we also include an area for comments about the error and an email address for contact purposes. I have mixed feelings about the Comments, Most people tend to leave them blank, yet send their email anyway. The comments were originally there for people to explain what they were doing that caused the error. We tend to use it internally, but as I said before most other users leave it blank.

Along with the comments we also keep a record of all information about their browser, their cookies, session variables, referer, form variables etc. Usually using this information we are able to quickly understand what caused the error and take steps to protect against it in the future.

Recently we had a series of errors that were caused by some stray characters at the end of a number 54w for example. We were not validating that this was a valid integer before looking it up in the sql table. Problem was the stored procedure expected an integer value. After looking at that we changed how we pass the value to the stored procedure, if it is a valid integer it is allowed through, otherwise it is sent as a 1 which fails to find any related articles and nicely informs the user that there is nothing to be found at that (54w) value.

Dunstan told me that their were no posts for the day I was looking for (not true their were two), but seeings as how SQL had already bombed out, I believe he was using the fact that the recordset had no records in it to generate that message. On the next line he told me that for the month of january, he had 25 posts, would one of those be the one I was looking for. This linked into his monthly archives as opposed to his daily archives. Next was a line with a link to his yearly archive, or perhaps to a list of monthly archives for 2004. I didn’t check because obviously this early in the year it must be in the January archives.

Looking in the January archives produced the same error, No posts in the month I was interested in. Could he suggest I look in the yearly archive, because he had 25 post for the year and one of those might be the one I wanted.

I was quite pleased to see, though definitely not surprised, to see this level of error handling. He gave a couple of options to the user as to a next place to look. The problem with the ie style error pages is that the only real course of action is to go back, back to the page that caused the error, or to what microsoft assumes is the homepage of the site.( From memory - the first thing I do when I have to use ie is to turn off those friendly errors)

Posted by Chris Clark Tue, 27 Jan 2004 03:31:00 GMT


Case Sensitivity

I was working on a design today, and ran into a problem with the display of an item when viewed in ie5/mac. I started with the usual adding a border. safari added the border no problems, ie failed to display it.

I thought I was dealing with another cased of ie causing problems. Instead i was pleasantly surprised to find out it was my error, I had changed capitalization between the class declaration and using the class in the html. IE5 was using a strict reading of the specs that called for Case Sensitivity, while Safari was case insensitive.

Posted by Chris Clark Mon, 26 Jan 2004 03:34:00 GMT


AOL Fixed

I managed to get AOL 9 to use the modem and dial out. It involved quite a bit of effort. removing the last try, reinstalling 9 which knocked out 6 and still didn’t allow aol to initialize and use the modem.

Found the original disks for aol 6 that came with the laptop. tried to install a seperate installation of 6 to at least allow us to dial out once again, no luck,

waol.exe has generated an error and will be closed

as I have said before what is the use of saying cancel in this case, you can’t cancel out of the error, you can only go on. At this point I removed all AOL instalations, using the uninstall feature found ineach folder.

Time to go out and get a new printer cable - visits home are rare so tech questions seem to pile up - reminds me I need to run the windows update before I leave.

Stop in Microcenter store, I can’t believe I am doing this but I actively scan the store looking for the aol display so that I can get my hands on one of the spam cds that i always pitch as soon as i receive them.

I see several displays but they all seem to be empty. Time to check out the specialty corners, wander in to the Mac shop and drool over the 12 inch powerbook, just what I need to spend money on at this point. Wondering out I find a full display at the front of the store, saving me the embarrasment of having to ask for one of those disks.

As we leave, mom asks why we needed blank cds,In case we need to reinstall the operating system.Needless to say she doesn’t sound too happy to hear this.

Success

Installing off the disk worked!!!

Now on to those critical updates. 200 minutes and counting

Posted by Chris Clark Fri, 16 Jan 2004 03:52:00 GMT


Older posts: 1 2 3 4