Tech Note: Bookmarklet Bug Fix

Exterminating an insect
LGF • Views: 16,523

Oops! A bug crept into the new LGF Pages bookmarklet code last night, affecting Firefox and Chrome users; the window would pop open but get stuck at the “Loading” screen.

The problem is now fixed, and it was something very simple — when testing a variable with “typeof,” the keyword “undefined” needs to be in quotes for these browsers.

Anyway, please re-install the “Create A Page” bookmarklet one more time so you’re up to date; everything is now working in all modern browsers. The latest version is 1.1.8.

UPDATE at 11/9/13 12:43:05 pm

How a bug happens:

I had originally written that section of the bookmarklet code as:

if (window.jQuery === undefined)

And that works in all browsers, without the quotes, because you’re comparing against the value undefined. However, this is problematic because it’s possible to declare undefined as a variable and give it a completely different value. Since a bookmarklet needs to be as unobtrusive as possible, I decided to change the code to use the typeof operator, like this:

if (typeof (window.jQuery) === undefined)

But I forgot that typeof returns a string, so you need to compare against ‘undefined’, in quotes, like this:

if (typeof (window.jQuery) === "undefined")

Except in Safari, which will happily do the correct comparison either way, with or without the quotes. I added that new code at the last minute and because it worked in Safari I made the mistake of releasing it into the wild. Safari tricked me by being too forgiving.

And that’s how bugs happen.

Jump to top

Create a PageThis is the LGF Pages posting bookmarklet. To use it, drag this button to your browser's bookmark bar, and title it 'LGF Pages' (or whatever you like). Then browse to a site you want to post, select some text on the page to use for a quote, click the bookmarklet, and the Pages posting window will appear with the title, text, and any embedded video or audio files already filled in, ready to go.
Or... you can just click this button to open the Pages posting window right away.
Last updated: 2023-04-04 11:11 am PDT
LGF User's Guide RSS Feeds

Help support Little Green Footballs!

Subscribe now for ad-free access!Register and sign in to a free LGF account before subscribing, and your ad-free access will be automatically enabled.

Donate with
PayPal
Cash.app
Recent PagesClick to refresh
The Pandemic Cost 7 Million Lives, but Talks to Prevent a Repeat Stall In late 2021, as the world reeled from the arrival of the highly contagious omicron variant of the coronavirus, representatives of almost 200 countries met - some online, some in-person in Geneva - hoping to forestall a future worldwide ...
Cheechako
2 days ago
Views: 92 • Comments: 0 • Rating: 1
Texas County at Center of Border Fight Is Overwhelmed by Migrant Deaths EAGLE PASS, Tex. - The undertaker lighted a cigarette and held it between his latex-gloved fingers as he stood over the bloated body bag lying in the bed of his battered pickup truck. The woman had been fished out ...
Cheechako
2 weeks ago
Views: 259 • Comments: 0 • Rating: 1