Category: Web Building

Javascript testing for NaN: why doesn’t !=”NaN” work?

A couple of weeks ago, I was working on a custom HTML wrapper for Captivate quizzes that would behave one way if a score were already stored for that quiz, and another if the score were non-existent or zero.

So, how best to test for the existence of a score? Usually I test for the existence of a value with


if (typeof foo != "undefined"){do something}

Continue reading

Enable the Debug Menu in Safari

I find the new debugging tools in Safari almost as useful as Firebug. There’s a Web Inspector that lets you see exactly how the HTML is formed, a Javascript console that lets you see errors and debugging messages written into the code and much more.

But to use them you must enable the Debug menu in Safari. Open Safari preferences in the Safari Menu, click Advanced, and select Show Develop menu in menu bar.

Continue reading

How to override the !important CSS style attribute using Javascript

I’ve worked on a few projects where a CSS style on some page element has been specified as “!important” and it interferes with the way the page functions. Ordinarily, I would just change the original style, but sometimes I don’t have control over the stylesheet or script that is generating the style. One example is a recent project where an embedded Captivate player is written to a custom HTML wrapper at by the javascript SWFObject.js. SWFObject writes style attributes to the page dynamically to hide the Captivate player as required until it is fully loaded:

object, embed {
              visibility:hidden !important;
}
Continue reading
Adobe Captivate

Adobe Captivate: Should I publish in ActionScript 2 or ActionScript 3?

Captivate 5 removed the need to answer this question: it only publishes in ActionScript 3 format, and correspondingly limits the compatibility of the published SWF file in certain situations as described below.

But if you are using Captivate v. 4 or earlier, you may still be wondering which to choose.

Continue reading

Spam prevention on Drupal sites

I run a Drupal site with several thousand users. Users self-register, and there are no other moderators but myself, so it needs to be virtually maintenance free to be sustainable.

And for years, it was! Since the site’s members are well-behaved, the only major maintenance besides keeping the Drupal installation updated was cleaning up spam posts. Usually, there weren’t many to clean: perhaps a few per week, but nothing that took a lot of work to get rid of. Early on, I had installed the Anti-spam module which provides three anti spam services to choose from. I selected Defensio, which offers a free filtering service for sites with less than 25,000 posts/month.

Continue reading