At 10/7/04 11:31 PM, BillGates wrote:
Well... I've abstracted the variable out of preference, it is more logical (nothing to do with standards), if I wanted to run more tests against the user_agent value
But this user didn't want to run more tests.
I won't need to type/compute all that crap again (eg, if I did what you did, testing for 'mozilla' as well as 'firefox' — it is a programming habit for easier expansion).
1. You're not computing anything. You're reading a string that's already been set.
2. With your example, you're typing MORE than you need to. Even if you put that variable into my example, you're typing MORE than you need to:
if((navigator.userAgent.toLowerCase().indexOf("mozilla") != -1) && (navigator.userAgent.toLowerCase().indexOf("firefox") != -1))
128 characters.
var user_agent = navigator.userAgent.toLowerCase();
if((user_agent.indexOf("mozilla") != -1) && (user_agent.indexOf("firefox") != -1))
133 characters (+ 1 if you include the new line).
My real point was the correct MIME type, dropping inline/hack commented code and dropping the obsolete 'language' attribute.
I find "obsolete" a strange choice of wording here, given that it still works in all browsers that currently support javascript (including Mozilla Firefox). Depreciated isn't even a decent way of describing it, given your comments below.
Eh? User agent is available as of Javascript 1.0. It has nothing to do with MIME type and isn't something that MSIE 4.01 and above can't handle.
Irrelevant. I'm just using the correct MIME type, as prescribed by standards. None of the IEs recognise the proper 'application/x-javascript' MIME type.
Awesome. Way to alienate the majority of the internet community. What you should be striving to achieve with all code (regardless of whether it always meets "standards") is to make it as accessible to all users, regardless of their browser and that (in some respects), is what I'm getting at.
I do not have your book, so would you care to elaborate and/or link to some reference?
Why bother. You'll probably come back with some "oh, well it's not documented in the Mozilla references, so that's ok" type argument... Despite the fact that the chap who created javascript invented these functions.
I've already conceded that Firefox probably follows more standards set by w3c than other browsers (particularly IE) way up in this thread. What you're not getting from my posts is that these standards mean shit to the end user - and by that, I mean the people who're parousing sites. They couldn't give a rat's ass as to whether the browser meets standards, they just get confused when they are used to having certain things work in one browser and not in another.
You have to accept that huge organisations like Microsoft are going to go off piste every now and then with features they create in their browsers. And that's not always a good thing and not always a bad thing. If Mozilla would include some of the good things that Microsoft have come up with (and other browsers as well), then everyone's online experience would be better and people coding all of this stuff wouldn't have as many headaches when it comes to more complex scripts.