It’s kind of redundant to post a “Get Firefox!” banner to someone already using Firefox, but it’s useful to show them an upgrade banner if they’re on an old version.  It’s also useful to show Firefox users a banner for Spread Firefox.

This can be done easily with PHP or other server-side scripting languages, but sometimes you have to use static HTML files.  That’s where client-side scripting becomes necessary.  Last month I posted some sample code that used document.write, which doesn’t work with XHTML.  (On top of that, the <noscript> blocks I used ended up causing validation errors because of their location!)

I’ve redone everything with DOM scripting, which will work with either HTML 4 or XHTML 1.0.

1. Put the following in a file called sfxlinks.js:

function replaceFirefoxLink(linkID) {
   if(linkNode=document.getElementById(linkID)) {
      var newLink=document.createElement('a');
      var newImg=document.createElement('img');
      var change=0;
      if ( 0 <= navigator.userAgent.indexOf('Firefox/0') ||
         0 <= navigator.userAgent.indexOf('Firefox/1.0') ) {
         change=1;
         newLink.setAttribute('href','YOUR_UPGRADE_LINK');
         newImg.setAttribute('alt','Upgrade to Firefox 1.5!');
         newImg.setAttribute('title','Upgrade to Firefox 1.5!');
         newImg.setAttribute('src','PATH_TO_BANNER');
      } else if (0 <= navigator.userAgent.indexOf('Firefox')) {
         change=1;
         newLink.setAttribute('href','YOUR_REFERRAL_LINK');
         newImg.setAttribute('alt','Spread Firefox!');
         newImg.setAttribute('title','Spread Firefox!');
         newImg.setAttribute('src','PATH_TO_BANNER');
      }
      if(change) {
         newLink.appendChild(newImg);
         var parentNode=linkNode.parentNode;
         parentNode.replaceChild(newLink,linkNode);
      }
   }
}

2. Use your regular Spread Firefox affiliate link and add a unique ID — let’s use id="FxLink" as an example — to the <a> tag.

3. Load the script in your document’s <head> section:
  <script type="text/javascript" src="sfxlinks.js">

4. Call the function in the body onload event using the ID you chose in step 2:
  <body onload="replaceFirefoxLink('FxLink')">

When the  page loads, the script will check the visitor’s browser to see if it’s an old version of Firefox or a current version of Firefox.  If it’s an old version, it’ll replace your standard button with your upgrade button.  If it’s a current version, it’ll replace it with a Spread Firefox button with your referral link.  Otherwise, it leaves the button alone.

This has a lot of advantages over the old version, including XHTML compatibility, no need for <noscript> blocks, easier validation, and it still degrades gracefully (if JS is unavailable or old, it leaves your normal button in place).

You can see it in action on my website, Flash: Those Who Ride the Lightning.

Originally posted on my Spread Firefox blog.

Remember when the web was young, and email was just gaining popularity in the mainstream, and there was a slew of virus hoaxes like the Good Times Virus, or It Takes Guts to Say Jesus, or Elf Bowling?

Remember painstakingly explaining to people that no, your computer couldn’t get a virus just by reading an email, you had to click on an attachment? That images were safe to open? Remember when the worst people had to worry about from web pages was unwanted cookies? Getting a virus just from looking at a web page? Preposterous! And a virus that ran up your credit card? Ridiculous!

It’s sad to think that all those “ridiculous” things are now possible—in fact, they’re commonplace. Look back at that link up there. It’s Snopes’ page on computer virus warnings. Way back when, they were all bogus. These days, most of them are real.

So what’s next? Well, they keep talking about Internet-aware appliances, so a future virus probably could “recalibrate your refrigerator’s coolness setting so all your ice cream goes melty.”

The WaSP is reporting that Microsoft will end support and cease distributing Internet Explorer for the Macintosh at the end of January. It’s been about eight months since the latest version of Mac OS X shipped without IE, and almost three years since Apple launched Safari.

While there is an “end of an era” feeling to this, it’s kind of like losing the last veteran of World War I. It’s of more historical significance than anything else. When Microsoft released IE5/Mac, it was hailed as the most standards-compliant web browser available. But Microsoft abandoned it years ago.

Fortunately, not only is Safari a worthy successor, but there are other options as well. What’s great about the web browser field these days is that the major players are constantly improving their offerings and working toward greater compatibility. And soon any website that wants to cater to Mac users will no longer be able to fall back on “Just use IE!” They’ll have to test in Safari, and of course the easiest way to build a website that works in IE/Win, Safari, and Firefox (the two defaults and the major alternative) is to start with standards-based code in the first place—which improves compatibility with even more browsers. Users get more choices, and websites get more users. Everyone wins.

I saw the planet Venus four times on my walk to and from lunch today! Yes, in broad daylight!

Someone on Slashdot mentioned it was possible last week. I took it seriously because back in high school, I used to watch Venus fade into the brightening sky on winter mornings. Often I could still find it once I arrived at school, since I knew exactly where to look.

I tried unsuccessfully a couple of times over the past week, but today I had a ~20-minute walk mostly facing southward, so I thought I’d give it a shot.

I used the Moon as a guide, trying to guess the distance based on how far apart they were last night. As I passed through a building’s shadow, I spotted a stationary white dot in the right area, a bit more than a hand span away from the crescent Moon in the direction of the sun, barely visible next to some wispy clouds. I couldn’t find any sign of a con trail, and it didn’t move, so it clearly wasn’t an airplane, but I was able to look away and back and still see it. Continue reading

Current Mood: 🙂excited

I found a flood of crude phishing attempts in our postmaster account this morning.

How crude?

The hook was, “Simply reply to this email with your online login and password.”

No forms, no imitation websites, no swiped logos, no links of any sort at all. One of them even had multiple recipients visible on the To: line. It’s like a throwback to the early days of spam-n-scam.

The headers were full of things like %RNDDIGIT27, suggesting a broken spam generator, and of course there’s the fact that they actually targeted the postmaster account.

»All pages site-wide with this tag