I am developping an AJAX website. Now I've ran into some differences between Standard JavaScript and Microsoft's JavaScript dialect.
For examle .textContent (standard) vs .text (microsoft) I could make two files, one for standard browsers and one for microsoft browsers, but if I make a change I need to do so twice, so, that's not an ideal option. Putting if statements around each time I encounter an .textContent doesn't seem like an optimal solution either.
So, I was thinkng about a script based solution, and I came up with something like this:
function translate_to_msie_dialect(){
var s = document.getElementsByTagName("script");
var l = s.length;
var i;
for ( i = 0 ; i < l ; i ++ ) {
var src = s[i].text;
s[i].text = src.replace(/.textContent/g, ".text");
}
}
I have tested this code on Internet Explorer version 8, and it seems to be doing it's job. (translating from ie to standard doesn't seem to work, standard browsers seem to execute the unaltered code instead)
The problem is, this only works for in-line scripts, and not for js source file scripts. Is it possible to do this conversion scripts for javascript files client side?
I could do a check on the user agent (server side), but I would rather do a check on the dialect itself, as some browsers support an 'identify as' feature and if they identify themselves as ie, they might get in a dialect they don't understand.