Thursday, November 8, 2007

MovieLandmarks.com now works with IE

I think I've solved the Internet Explorer problems with the site. The fixes were pretty simple:


/* Replace getElementById with a function to try it the right way first,
then the IE way
*/
document._getElementById = document.getElementById;
document.getElementById = function(id) {
var e = this._getElementById(id);
if(!e || e.id == id)
{ return e; }
return window[id];// try the IE way
}


IE apparently doesn't implement getElementById properly, so if it fails you try using the window method. This seems to have fixed all of my div id lookups.

The google map also wasn't displaying, this was because the 'map' variable wasn't declared in the global scope first (in Firefox if there is no var it assumes global, in IE apparently you have to explicitly declare it first). Simply adding var map = null; at the top of the javascript solved this problem.


I use the GDownloadUrl() function for all my back end calls, so compatibility isn't an issue there.

Let me know if you have any problems viewing in IE.

No comments: