opening it up with Common Lisp

Favorite weblogs

Lisp Related

Bill Clementson

Finding Lisp

Lemonodor

Lispmeister.com

Planet Lisp

Politics

Orcinus

Talking Points Memo

This Modern World

Working for Change

Other home

Polliblog

Recent Readings

Book review: Darwinia
Reviewed: Friday, August 11, 2006

Summer reading: Spin
Reviewed: Saturday, August 5, 2006

Runner
Reviewed: Tuesday, July 18, 2006

the Omnivoire's Delimma
Reviewed: Wednesday, July 12, 2006

the Golem's Eye
Reviewed: Wednesday, May 31, 2006





tinderbox
 width=

Javascript / DOM / browser silliness
Thursday, March 30, 2006

I've been working on a small project for Franz using AJAX and other happy buzzwords. my goal is to place the application on one of my home computers (metabang.gotdns.com -- a site that isn't particularly complete or maintained but I can use it as a Lisp server...). The application serves up HTML pages with images and imagemaps. When you click on various parts of the image, some AJAX happens to replace the current image and map.. It's pretty nice and everything worked fine in my browser of choice (OmniWeb -- love those tabs and workspaces!) but Firefox and Safari didn't quite click. In Safari, every other image served would work. In Firefox, only the first image served was happy. Here's the Javascript code that updates the imagemap:

if (placeholder) {
	   var mapString = getXMLDatum(root, "map");
	   if ( mapString && mapString.length > 0) {
			   placeholder.innerHTML = mapString;
	   } else {
			   placeholder.innerHTML = "";
	   }
}

Not much to change there but on a whim, I pulled the "set to empty string code out of the else":

if (placeholder) {
	   var mapString = getXMLDatum(root, "map");
	   placeholder.innerHTML = "";
	   if ( mapString && mapString.length > 0) {
		placeholder.innerHTML = mapString;
	   }
}

Believe or not, this change was enough to convince Safari to work on every image map. (and If anyone knows why, I'd like to hear about it). Firefox, however, could not be mollified so easily. I used the built in DOM inspector tool and it turned out that the map area information was being modified. So, I reasoned, it must be that the image wasn't noticing... The code to update the image was the simple:

if (imageEntity && baseName) {
	imageEntity.src = "./temporary/" + baseName + 
	".jpg?time=" + now.getTime();
}

I changed this to:

if (imageEntity && baseName) {
	imageEntity.setAttribute("usemap", "");
	imageEntity.src = "./temporary/" + baseName + 
	  ".jpg?time=" + now.getTime();
	imageEntity.setAttribute("usemap", "#G");
}

This did the trick (which, I assume, is a rather odd reference to the game of bridge?). If you ask me, neither of these things should have be necessary (and weren't, after all, for OmniWeb which, if I recall correctly, uses the same WebKit rendering image as Safari so... end the sentence and go figure.)

The moral of the story is the usual one: "software sucks".


|

Home | About | Quotes | Recent | Archives

Copyright -- Gary Warren King, 2004 - 2006