I was wondering if someone could take a look at this short script, and tell me why it not working with just "else" but works with "else if"? I assumed, (i guess, mistakenly), that in some instances, there is no difference between else and else if.
Thank you very much for your help.
Code:
<Doctype html>
<html>
<head>
<title>
AJAX
</title>
</head>
<body>
<script>
var httpRequest;
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
alert("HELLO");
}
else if(window.ActiveXObject) {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
</script>
</html>
</body>
</html>
I was wondering if someone could take a look at this short script, and tell me why it not working with just "else" but works with "else if"? I assumed, (i guess, mistakenly), that in some instances, there is no difference between else and else if.
Thank you very much for your help.
Code:
<Doctype html>
<html>
<head>
<title>
AJAX
</title>
</head>
<body>
<script>
var httpRequest;
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
alert("HELLO");
}
else if(window.ActiveXObject) {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
</script>
</html>
</body>
</html>
Code:
<Doctype html>
<html>
<head>
<title>
AJAX
</title>
</head>
<body>
<script>
var httpRequest;
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
alert("HELLO");
} else {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
alert(httpRequest)
</script>
</html>
</body>
</html>
thank you very much for the code. if i replace else if with else in my code, the firefox error console tell me that there is a syntax error and shows me the line with else statement. I don't understand why it happens
Code:
<Doctype html>
<html>
<head>
<title>
AJAX
</title>
</head>
<body>
<script>
var httpRequest;
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
alert("HELLO");
}
else (window.ActiveXObject) {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
</script>
</html>
</body>
</html>
I see hits from at least 4 different users on one of our sites just yesterday, all using MSIE 6.0, believe it or not. One of them even using Windows 98!!
Three of those IE6 users from France, one from Canada.
(Granted, that is 4 users--18 page hits total--out of over 26,000 page hits. So less than 0.1%. But it's clearly not zero.)
So for now, at least, I think I'll keep providing for IE6, unfortunately.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Oh, wow! It's a *LOT* more than I thought! Teach me to use too small a sample!
4533 unique IP addresses yesterday.
79 (yes, really, 79!!) were using MSIE 6 !!!
That's ALMOST 2% of our users!
WHEW! Sorry, but I don't think I'm ready to abandon MSIE 6 support, yet!
Just for grins, I also queried for MSIE 5. You ready for this: 10 IP addresses still using MSIE 5.5 and even ONE still using MSIE 5.0!!!! (the 5.0 user was another Win98 user).
WOW!
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Not at all! In fact, a lot of the newer pages are really designed to take advantage of some fairly advanced features of CSS.
I was blown away to see those MSIE 5 people still hitting the site! It scares me to wonder what some of those pages may look like, to them.
I suspect I'll be talking to the page design guy tomorrow! (I do mostly the backend stuff and then the JS needed to support it all, but leaving most of the actual design decisions up to him.)
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.