Friday, November 30, 2007

AIS from Pietarsaari, and tracking links fixed on MSIE

OH6AG kindly started to provide AIS reception from Pietarsaari. Their receiver hears traffic from the harbors of Pietarsaari and Kokkola, and most of ships from Kvarken (Merenkurkku).

I also did a small but important fix on the map javascript code - the "start tracking" and "stop tracking" links now also work on Internet Explorer 6. For some reason the quite correct way of assigning an onclick event to a span did not work on that single browser - it did work on every other browser (including IE7). And it only failed to work in the innerHTML dynamically generated by the javascript for the target info pop-up balloons - it works just fine in, for example, the Options link on the right side of the map (which is dynamically generated on the server). So I put in a <a href="javascript:function()"> tag, which seems to work on at least Firefox, IE6/7 and Safari. Please let me know if this change broke some other browser.

2 comments:

Anonymous said...

MSIE does not handle adding inline events in innerHTML.

so setting:
'<span onclick="foo();">bar</span>'
as the innerHTML will fail.

likewise, setting the attribute in DOM methods will fail too.

spanObj.setAttribute('onclick','foo();');

To make this work, you need to apply an event listener (that works in all browsers (because IE doesn't follow the spec)

Look for "Dean Edwards" approach, it works pretty well.

Hessu said...

Ah, thank you for the note. That explains. Have to spend some time reading Dean Edward's blog, seems like there's plenty of good stuff to be found there.

I just remembered that I've been using an event listener in some rather similar code I wrote at work a couple years back. :) This will be needed for making the translation tool to work on MSIE, too.