Recently, one of our clients had a Javascript related problem on their Blackberry 9000 devices. An Intranet page, which used to work properly in former Blackberry models, stopped working on their new Blackberries.
The same page works well on Internet Explorer, but doesn’t work on Mozilla Firefox either.
Upon closer inspection, I have found out that this is a Javascript related problem. Here is the code snippet from the problematic page:
(…….)
url += document.getElementById(‘ans’).value;
(…….)
<select name=ans>
<option>…</option>
</select>
The error occured on the getElementById command. The reason is; Blackberry 9000 (and Mozilla) makes it mandantory to have the document elements the “id” property defined. Here is the corrected code snippet:
(…….)
url += document.getElementById(‘ans’).value;
(…….)
<select id=ans name=ans>
<option>…</option>
</select>
And that works like a charm.
Blackberry probably changed it’s Javascript engine on their new models and turned to Mozilla. You may think that it’s a problem with Mozilla & Blackberry, but actually it’s a “problem” with Microsoft. According to the HTML DOM, the first code snippet isn’t supposed to work at all – because HTML elements must have their “id” property defined so that getElementById works. Check http://www.w3schools.com/HTMLDOM/met_doc_getelementbyid.asp for reference.
This means; Microsoft’s Javascript engine tolerates the missing “id” property and has the ability to use the “name” property instead. Mozilla and Blackberry is working as intended and as defined in DOM. However, because of Microsoft’s extra tolerance; websites tested on Microsoft Internet Explorer only make Mozilla (and probably other browsers) look buggy.
Leave a Reply