The August 2004 Blog
send me a comment

Debugging Random JavaScript Crashes (Tuesday, Aug 31)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

I've been making some modifications to my JavaScript Calendar code so I can use it as a drop-down DHTML calendar/date control on a web page. I got everything working, but I found that if I opened and closed the control a bunch of times really fast, and clicked the next and previous month buttons as quickly as I could over and over again, that I would occasionally crash Internet Explorer. Not always, and not very consistently, but it would sometimes happen, and always when I was clicking buttons.

I've seen this happen randomly before, in other scripts that I've written. For example, if you go to my JavaScript Search and Highlight page and click any of the buttons and press 'Enter' to accept the dialog box default over and over as fast as you can, you'll sometimes get the crash on IE. It never crashes Mozilla, and the script isn't getting any errors, so I generally just chalk it up to an Internet Explorer bug and cross my fingers that no one will ever intentionally try to break the page like that.

When I've run into this in the past, I've spent a lot of time searching Google and Yahoo and various forums to see if anyone has any insight, but I've always come up blank. I decided to try again, and after a lot of different searches I think I finally found a lead.

First, I found a reference to an Internet Explorer memory leak. The people at webreference.com noticed a memory problem with their script, found a Microsoft technote about it, and said that despite the fact that it was supposed to be fixed somewhere in the IE5 codestream, it still exists. They even provide some code to reproduce the issue (which becomes apparent if you run the script over and over with Task Manager running). They also mention that their solution was to dereference all of their JavaScript DOM objects (setting them to null) when the user leaves the page.

I tested that out on my pages, and found that I wasn't really getting any increases in memory allocation, and I wasn't really using very many DOM objects (directly) in my code, so I pretty much ruled that one out. After a while I came across a reference to another Microsoft technote entitled BUG: Internet Explorer Stops Responding When You Dynamically Insert Table That Contains [Input Type="Button"], which begins with this information:

Internet Explorer generates an access violation and stops responding (crashes) when you dynamically insert a table that contains the following

<input type="button">

into a Web page by updating the innerHTML of a div.

This behavior can occur if a mouse event is pending and you wipe out the control that initiated the mouse event before the mouse event returns.

Yup, that's almost exactly what I'm doing. In all the scripts where this is a problem, I'm rewriting all or part of the page using innerHTML, and in all these scripts the button that's calling the innerHTML rewrite is inside of the area that I'm rewriting. And it makes sense that this could cause problems, really. The object that's spawning an event is getting destroyed before the event is complete.

I played around with window.event.cancelBubble=true for a while, but that never seemed to completely fix the problem, so I think I'm going to try to place the button outside of the refreshed area and see if that helps. I also need to check to see how backwards-compatible the <button> element is, because that may be an easier solution in the end.

I was amazed that I had never seen that technote in all my searches (it shows a Last Reviewed date of over a year ago), until I realized that it doesn't come up in a search on search.microsoft.com for "javascript crash" or even "innerHTML crash". Seems like the magic search string is "innerHTML access violation". Ah, of course...

Desktop Wallpaper From Sunset Key (Thursday, Aug 26)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

We just got back from a family vacation down at Sunset Key, right next to Key West. Beautiful place. They call it "Sunset Key" because at night, as you're looking out from the touristy areas of Key West, the sun sets just over that little island. Here are a couple of nighttime pictures I took, sized to 1024 x 768 and resaved at 72 dpi (because the original pictures are a bit large @ 800 KB). They're rather pleasant to look at as desktop wallpaper, if I do say so myself...

A ship sailing by at sunset
The sun going down over Sunset Key

Hairboy (Thursday, Aug 19)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

Care of my older brother (thanks J-P), here's a story about the hairiest man in China. He has hair covering 96% of his body. That could make for a serious 5 o'clock shadow.

What he really wants to be is a rock star, though. I love this quote:

"I hope to prove myself and others wrong in singing some day. Of course, in the beginning, people will say, that's just "hairboy" singing."

Yup, that's probably what they'll say...

Two Years (Wednesday, Aug 18)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

Today, my site/blog is two years old. Yay me.

Just like last year, here are some of my favorite topics from the past 12 months:

Thanks as always for stopping by. I'll catch you on the flip side.

Flies In Your Eyes (Monday, Aug 16)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

I was going to talk about something from work tonight, but decided against it because (A) it wouldn't be interesting to anyone but other people I work with, and (B) I really shouldn't be talking about work on this site.

However, part of the story was going to involve the line from Catch-22 where Appleby can't see the flies in his eyes because he's got flies in his eyes. And I realized that some of my readers wouldn't get the reference, because even though lots of people have some basic understanding of what "Catch-22" refers to, many people probably haven't read the book.

So, for reasons of cultural literacy, I decided to put the relevant part of the story on my site. You can now read exactly what Catch-22 means here.

Wacky Weather (Friday, Aug 13)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

So, we've got this Hurricane Charley thing that's supposed to blow over Jacksonville tonight, and I think every conversation I had today contained either the word "hurricane" or "disaster recovery". Woo boy. This is one of those situations where IT has created its own problem -- if it wasn't for all these computers, there wouldn't be much for us to worry about from a disaster recovery standpoint, would there?

To add a little weirdness to the day, as one of the bands of Tropical Storm Bonnie passed by, we could see two tornados in the distance (maybe they was just funnels, but it sure looked "tornadic" from where we were sitting). Then I went back to my office, and outside my window was snow! That's right, snow. At first I thought it was hail, but it was white and flakey and blowing around...definitely snow-like. That lasted for about 2 minutes, and then the torrential downpour moved in.

Now I'm home, just waiting for the weather. I think the bad stuff is supposed to hit around 2 AM, so it might be a restless night. At least we're not evacuated, though.

Delaying Your Windows XP SP2 Update (Wednesday, Aug 11)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

In case you didn't realize it, Windows XP SP2 will be pushed out as a "critical update", not as something the you have to seek out and download (or have installed by your friendly neighborhood IT guy). This means that your user base can end up with SP2 on their machines as an auto-update.

If you need a little more time to test the workstations in your environment, Microsoft has provided instructions for Temporarily Disabling Delivery of Windows XP Service Pack 2 Through Windows Update and Automatic Updates. You never know when that might come in handy. It only works until December, though.

To help you along, there's a lot of information about planning your SP2 "deployment" on the SP2 Resource Site.

Men In Pink (Tuesday, Aug 10)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

As I said before, if I actually notice a fashion trend, that must mean it's a real trend:

From New York Newsday: Men In Pink

I have a feeling I'll be sitting this one out, much like I did the first time it happened in the late 80's. Of course, what's really going to noodle me later is: was this really a trend before I blogged about it, or did all the hip Italian designers who read my blog pick up on it after they read it here...?

;-)

More LotusScript Classes: CXVtoXML 1.1, XMLChars, and StringBuffer (Monday, Aug 9)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

As I was digging back through old code the other day, I found all sorts of stuff. Here are a few items for public consumption:

If I get some time I'll clean up a few more routines I found, just in case they might be useful.

CSV to XML (Sunday, Aug 8)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

At the office I've been working on a project that involves some file processing. One of the files in question is an XML file, and I've pretty much got that parsing routine finished and debugged. The other file is a comma-delimited file, and I'm trying to figure out how I want to deal with that one.

I've got plenty of CSV file processing examples in my toolkit, so I can piece together some old code to get something working pretty quickly. However, I was wondering if I should convert the CSV file to XML first, and then reuse the XML parsing class that I'm using for the other file. That would add some overhead on the front end, but it might make things more consistent overall.

Just in case I go in that direction, I shuffled some old functions around this weekend and wrote a helper class. You can download it and take a look in this latest tip: Convert CSV Files To XML. It's a LotusScript class that reads a CSV file and writes its contents to a new XML file. You can specify certain parameters like the delimiter character (usually a comma, but sometimes a tab), the XML encoding for the output file, etc. It also properly handles quoted strings with embedded delimiter characters and linefeeds. See the code for details.

I did this in LotusScript because it's easier to debug a LotusScript agent than a Java agent. You should be able to easily convert this to Java if you need to. It also uses some ND6-specific functions that you'll need to replace if you want to use this in R5 or earlier.

Happy Birthday Lando (Friday, Aug 6)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

Disclaimer: I was not the originator of this picture (as much as I'd like to take credit for it). It's from Volker's LotusWars wiki page. Click the picture to go there.

Candy Cigarettes (Wednesday, Aug 4)
[ permalink ] [ GoogleTrack ] [ e-mail me ] [ >> ]

We went to a kids birthday party this past weekend, and on the way home we were looking through the goodie bags that our children got. Here's a summary of the conversation:

Me: Did they get anything good?
Wife: There's some candy in here. Sweet tarts, candy sticks...
Me: Candy sticks? What are those?
Wife: You know, those little white sticks of candy that look like chalk. When you were a kid you used to pretend they were cigarettes?
Me: Actually, I think they were candy cigarettes when we were kids.

Funny how times change. Heck, in 30 years they probably won't be called "candy sticks" anymore either. They'll just be called "sticks". Just like how "Sugar Frosted Flakes" became "Frosted Flakes", and "Sugar Smacks" became "Smacks".

Even the really old Cheerios ads (before my time, but I've seen them in magazines) used to have a little boy running and jumping and zipping around a room, with the slogan "He's feeling his Cheerios". These days that's right out. Soon they'll be advertising breakfast cereals that actually sedate your kids -- "Sluggies: the cereal that slows 'em down".