April 2005 Archives

April 22, 2005

JavaScript, Duplicate Cookies and Paths

While the new SoftwareMedia.com doesn't require JavaScript, it does use it in a few places for enhanced functionality, such as the Specials marquee and the expanding categories on the right side. For these enhancements, it uses cookies to remember the state of things. This ensures that no matter where a visitor navigates throughout the site, if he/she has turned the marquee off or expanded the hardware category, it will stay that way.

Only it wasn't consistent... sometimes it would remember your preferences, sometimes it wouldn't. Doing some casual JavaScript debugging revealed that there were duplicate entries in document.cookies. As it turns out—this should have been a no-brainer—when you set a cookie in JavaScript, if you don't specifiy a path, it will default to the path of the current page.

Suppose a script on a weppage (http://foo.bar/path/) sets a cookie via JavaScript:

document.cookie = "selectedCategory=hardware";

If the visitor then navigates to the home page (http://foo.bar/) , scripts on that page will be unable to access the "selectedCategory" cookie. If a script then sets the cookie to "software", when the user navigates to the original page (http://foo.bar/path/), there will be two occurrences of the "selectedCategory" cookie in the document.cookies object and scripts will have no way of knowing which one is the correct one.

Moral of the story: Always specify a path when setting cookies via JavaScript.

Posted by jon at 2:58 PM | Comments (0)

April 11, 2005

alter table, sort of

The good people over at SQLite and AOL have done it at last... almost. SQLite 3.2.1 now supports basic ALTER TABLE statements. You can now add columns and rename tables, all the while preserving existing data, indexes, and so forth.

There is still some work to be done, namely the ability to change and drop columns, as well as manipulate indexes, but this is a huge step in the right direction.

For those who cannot upgrade, or who need to do more than just add columns, there is still my PHP SQLite class for this purpose. You can use it to add, change, and drop columns, although manipulating indexes still hasn't been implemented. Whether SQLite or I get to that first is anybody's guess... if only I had some free time...

Posted by jon at 5:35 PM | Comments (0)

April 7, 2005


March 31 marked the launch of the brand-new, standards-based softwaremedia.com. I came on board as CTO back in November, and one of my main goals was to make sure best practices were followed in the creation and launch of the new web site.

Another firm had originally done the redesign, and although the graphic design was top notch, the code was a tad disappointing (read: 1998). Tables, Flash, tables, spacer gifs, tables, JavaScript navigation/redirects and tables. Lots of semantically meaningless code, making accessibility and SEO a joke.

In the end, we redid the site from the ground up with standards in mind. It still needs a little more work before I'm satisfied — validation isues and IE Mac — but it's almost there.

What we did:

No Flash. No tables except for tabular data. Few images. JavaScript only as an enhancement and not a requirement. Lots of CSS. Lots of semantically rich content. Optimized for search engines and accessibility. Smaller page weight.

The end result:

More business and lower overhead, something anyone can appreciate.

Which begs the question: Why are so many web design firms still stuck in 1998? Did they not get the memo? And more importantly, why are companies still hiring them?

standards-based : 90's-based :: mammals : dinosaurs

So where's that asteroid when you need it?

Posted by jon at 7:44 PM | Comments (0)
November 2010
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30