- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
never had the courage to write that comment....
Admin
I like also how the IE7 stuff is commented out.
My favorite is several lines up:
<!--[if IE 6]> <link media="screen" href="/vstatic/16cce2360fa5810fe5ae3c8b076d0009/static/css/ie6.css" type="text/css" rel="stylesheet"></link> <![endif]--> <!--[if IE 7]> <link media="screen" href="/vstatic/16cce2360fa5810fe5ae3c8b076d0009/static/css/ie7.css" type="text/css" rel="stylesheet"></link> <![endif]-->All commented out, mind you. Good thing this is production-quality code!
Admin
Looks reasonable. With Javascript you reach a point where there's nothing to do but plead
Admin
IE supports conditional comments. See here: http://www.quirksmode.org/css/condcom.html
Admin
Say what you will, but it worked. I viewed the page from IE7 and it didn't crash. ;-)
Admin
I had no idea, interesting. I like it.
Admin
oh ffs, that is the real WTF, though I can see it is useful in situations that shouldn't arise in the first place.
Admin
The question is whether implementing such non-standard features in a browser solves the problem or IS the problem.
Admin
Admin
IE's solution is by far the most elegant way to check which browser the client is using, and act accordingly, regardless of why you need it. For all other browsers, you need to check for non-existant properties/methods/whatever in Javascript, and then act accordingly within the Javascript - terrible idea if you need to add special CSS, and the method will obviously fail when the user doesn't have JavaScript enabled, or when the browser you're handling adds that property, but doesn't fix the reason you put it there in the first place. User-agent checking is utterly useless and unreliable, as it's extremely easy to change it.
As long as any browser that is even remotely likely to be used for your site, doesn't render 100% according to standard (last I checked, Opera was the closest, but not perfect), you need a way to differentiate between them to work around limitations. Using Javascript is okay if only the Javascript needs to be different, but if you're trying to avoid a bug in a Firefox' CSS engine (of which there are plenty), that's when conditional comments would be very handy, as they are 100% reliable.
Admin
I think the real WTF is the compression used in that pic.
Admin
The W3C is a joke. It takes years of idiotic committee bickering to get anything done, and when they finally do make a decision, it's usually half-assed.
Reminds me of AJAX. When Microsoft invented it (yep, you read that right, they invented it), everyone bitched about how it was useless and how it broke standards, yadda yadda.
But then people realised how useful it actually was, and embraced it like crazy.
Yell at MS for "breaking" standards if you wish, but honestly, that's ridiculous. MS, like most web developers I know, is sick of the W3C dragging its heels on shit that should have been made 10 years ago.
Admin
The alternative to conditional comments is the horrible system of hacks many CSS "gurus" use, which involves exploiting various parsing errors in various versions of IE in order to allow parts of the CSS to be bypassed or not, depending. For some reason they feel this is a better solution (and then moan when something new - like IE7 - comes along which isn't bug-compatible with IE6)
Admin
And other browser vendors apparently agree, as both Firefox and Konqueror have stapped beyond the limits of the W3D standards.
Admin
I know the pain, because programming JS cost me a significant number of hair already.
I must say, though, that discovering the 'Prototype' library has eased my pain considerably. I really helps to get things done in a browser-independent way.
/sascha
Hm, captcha is "doom". Does that mean anything? ;-)
Admin
Saying that Microsoft invented AJAX is such a simplistic view of AJAX that it's plain wrong. Microsoft invented the XMLHttpRequest object, which is a very important part of the group of technologies we call AJAX. The iFrame as well as Netscape's scriptable layer element are both precursors to AJAX and had a strong influence, making XMLHttpRequest more of an evolution of existing ideas rather than a completely new concept. DHTML is the rightful precursor to AJAX as a way to make pages dynamic and even dynamically include server side content.
Admin
He should also offer a cigar and rum to Jobu!
Admin
Javascript has been a WTF from the start. So it isn't surprising that it grows into a bigger WTF as time marches on. When you start with a foundation of shit, it's not unexpected that you will find a shaky, unstable building on top of it.
A bit of history. Javascript started as a netscape 3.0 invention. It was designed as a "quick and dirty" way to get Netscape to do cool things, since HTML was not designed for the sorts of behavior needed. There was no Javascript "standard" back then...there didn't need to be. Netscape WAS the standard.
IE4 and 5 come along and takes up the torch, adding more crud (and features, sometimes hard to tell the difference) to the javascript language. Netscape dies out (and I'm not sorry to see it go, Netscape 4.x is one of the biggest WTFs in history, IMO) and IE's javascript is now the "standard". Oh, there's an EMCA standard by now, but let's not kid ourselves, the true web standard continues to be whatever the most popular browser is at the time, bugs and all.
Firefox comes along, taking a significant share from IE. It too, adds it own javascript features/crud, further adding to the nightmare that is cross browser compatibility.
What's worse, is now that "AJAX" has come along, javascript has become even more integral to the browser "experience".
Further, new web cool web browsers will come along (those who believe it's "Firefox forever" are deluding themselves, history says otherwise) they'll add their own "flavor" of javascript, thus muddying the waters further.
So to some up, a quick and dirty hack of a scripting language becomes something that it was never intended to when it was conceived. As as result, web developers will continue to be pulling their hair out in the forseeable future.
Admin
Admin
One would expect the JavaScript standard to have some builtin value that lets one know what the browser is... But, of course, it couldn't really get anything usefull on it.
I also don't blame Microsoft for the crude workaround.
Admin
Actually JavaScript was originally called LiveScript not JavaScript. Browsers are evil and the only thing that matters is how it renders in Dos, if it passes the stupid xhtml 1.0 validation test, and google can properly index it. So that said everything should be made in Falsh that way you can tell the browser to go to hell! Natch!
[This site made in Notepad]
Admin
The real WTF is that people still believe in the "conditional comments" nonsense. If they would actually try, then they'd notice that it doesn't make any difference if you write "if lt IE6" or "if gte IE6" or "if lt IE7" of "if lt foobar" or "omgwtf" or nothing at all. There is no such thing like conditional comments, it's Microsoft's lame excuse for not properly implementing the parsing of SGML comments.
Trivial test case:
<!-->This is a HTML comment. Don't show me!<!-->Admin
hmm why not use javascript to load javascript files and render them... you know run the check the browser and then use ajax to load you neat well made browser specific javascript....
you know something really easy to maintain like this:
<script>document.write("\<script\>document.write(\"foo\");\</script\>");</script>Admin
Really? What got added? As far as I can tell, the mantra amongst developers is "Code your site correctly, then make it work in IE"
I think you're stuck in the 90's.
I think you'll find that the language isn't to blame. It's the browser implementation of the language. Just because IE is the majority browser, it doesn't make it's implementation more correct. In fact, the biggest problem between IE and the rest of the world lies in it's handling of CSS rules rather than it's JavaScript engine.
Most of the issues that exist between the browsers now are relics of the poor implementations of the past. For example, Microsoft held on to it's old style of event management to maintain compatibility with older web pages - thus we still have memory leaks in IE.
Admin
Using Javascript to determine what stylesheets to load... now that is a real WTF.
Conditional comments are a far more elegant and performant solution to the problem of backwards compatibility.
Admin
That's not commented "out" - that's how IE's conditionals comments are. Go read:
http://msdn2.microsoft.com/en-us/library/ms537512.aspx
Admin
Two wrongs <comment>do not</comment> make a right?
Admin
Not to sound like a JavaScript apologist, but I think this is a little harsh. The problem, as far as I can see is, is not with Javascript [the language] as it is with the shoddy bindings to the various browsers.
As a language in itself, JavaScript has a lot of nice features that make it well suited to application automation - loose typing, first class functions and closures. The design of the language is compact, reasonably elegant, and more orthogonal than most. The syntax is easy and familiar to almost anyone who has programmed one of the C-like family (which includes PHP and Perl as honorary members, I guess).
However, I agree that the 'design' of the browser environment it commonly runs in is dreck. It's a lot nicer now that there's access to the XML DOM methods across all the major browsers, meaning that you don't have to jump through hoops to figure out which container to look in for your objects, but it's still a gnarly collection of badly thought-out mismatched APIs. And then you have CSS, which has its own collection of idiocies to layer on top.
It does concern me that AJAX is rooted in such an ad-hoc environment. It is obviously not the best solution for distributed application delivery, but then the web browser has always been a nasty, limited place to run applications. That hasn't stopped us all from writing and using web apps for the last ten years, though. The platform is a ubiquitous lowest common denominator, and it turns out that the benefits it delivers (zero installation, easy centralized roll-out of functionality) outweigh most of the other technical considerations, simply on the basis of cost. We are going to be stuck with it, regardless of what we feel might be better.
Admin
There was a bug in IE that caused the page to crash whenever the DOM element containing the comment was empty. It didn't matter what was there as long as it was something, so one of the devs added the "please don't crash" comment. And IE listened.
Admin
Oh man, that reminds me. I recently had to maintain some Javascript/HTML code that was supposed to display an error message if the browser wasn't IE. Of course, the script was written in JScript, so non-IE users saw a blank page while IE users saw what they were supposed to see.
I fixed it by removing the browser check and rewriting a few lines of script so that all browsers later than NS4 could see the page perfectly fine.
Admin
Admin
Well I guess I'm in the wrong crowd here but AJAX does break standards if used inappropriately. Many a muppet has gleefully broken previously accessible sites, without thinking to develop for other previously perfectly working platform/browsers because... "Aye! It wuks on IEee on me Winduz box, like." ...so that must be alright then.
As for the W3C, well there's nobody in the industry who thinks the the rubbish that happened in the browser wars was good. It took years to get everybody back on the same track and even now we "need" IE conditional comments. I'd rather wait for robustness and standards than spend endless development hours reworking code for every browser and platform there is.
We actually had the ability to do AJAXy stuff without XHR. People smart enough to know how were smart enough not to go splashing it around at every opportunity. </soapbox>
But I digress, the plea in the comment mad me and everybody in the office laugh. The rest of the <head></head> code was fine AFAIC although I would try to design without the need for conditional comments.
Admin
I am the author of this little snippet of joy. During the final frantic stages of getting Zillow out the door, a bug was discovered where if a certain DIV was completely empty, IE6 would crash. Hard. It was likely a combination of the DIV naming and the CSS being applied, but we didn't have days to waste tracking it down. In desperation, I added this comment to see if simply adding anything to the DIV would prevent the crash...and it worked. I suppose I could have been more cryptic, but as we all know it's important to future maintenance that any code be self-explanatory.
Given major changes to the DOM structure and CSS of the site, it's likely that this comment isn't even necessary anymore, but I've always liked the fact that I fixed a crashing bug with a comment. Plus, it got me on WorseThanFailure.com, and how many devs can say that?
Oh, and while the Javascript discussion above is interesting, keep in mind that this bug had nothing to do with scripting, but with the DOM and CSS in IE6. Even with no script at all on the page, it still crashed...
jeff
Admin
Or the user can DISABLE it entirely, or perhaps their network administrator has locked down their browser security settings, or...
There are a myriad of reasons that javascript might not work. There is NO WAY to guarantee that javascript will work, therefore it is completely useless and anyone who relies on it is a fool.
Admin
Admin
Microsoft did this. And last time I checked msdn, they stated they were not going to change it, for backwards compatibility reasons.
Admin
Admin
Eww, i'm taking that back - it doesn't. Half-fixed, oh my.
Admin
Yes, Google developers were such fools to write Gmail. There's no way anyone's going to use that piece of garbage, because they just might have Javascript turned off and be completely unable to figure out how to turn it on again.
Admin
I have to deal with reconciling standards-compliant code with IE's buggy box model all day long. Conditional comments are SOOOOOOO useful. It's much easier to keep two separate CSS files -- one for everyone, and one for IE. You render the standard one first, then render the IE one and have it overwrite the CSS rules that need fixed.
It's clean, easy, and it WORKS (even as far back as IE5!).
It's quite frustrating when you finally finish all the CSS styles in Firefox / Safari, and all of a sudden you realize that it totally displays incorrectly in IE. And whoever said that MS created the XHR is indeed correct. They did create it way back in the day. It was just never effectively implemented until recently.
Oh -- and to fix the code author's problem with IE crashing from empty DIV tags: stick an in there. That's enough to keep IE happy.
Admin
How do you do it with the Netscape 4 model? Well, first you have to make a new hidden layer, with the SRC being the bit you're requesting from the server. Then you read from the... wait, what? no document.read()?
"AJAXy stuff" requires the ability to make fresh data from the server available to a script.
IE4's InnerHTML/InsertAdjacentHTML/etc model was the first one in which anything resembling AJAX was possible. Minimally, you need to be able to load a second document (e.g. in a frame), and get the content out of that document so you can do scripty things with it.
Admin
BTW, It's funny how many developers like to disparage Javascript because of browser/DOM issues. The language itself is actually quite elegant, much more so than PHP, Perl, VB or a number of other popular languages. Mostly those who hate it fail to understand it. Spend some time at http://crockford.com/javascript/ and you might develop a newfound respect for Brendan Eich's brainchild.
Personally, I think a developer's attitude toward Javascript might be a perfect assessment of experience:
Newbie: Javascript is so cool! I can make things move in a web page.
Coder: Javascript sucks! What a piece of trash language! I mean, you can't even write classes in it. And what's up with that weird function.prototype thingy?
Hacker/guru: Javascript is such a nice clean language! Too bad there's no good implementation for general programming. It would make a better all-purpose scripting language than most of the other crap we use. Imagine a Unix shell using Javascript!
Admin
I'm actually looking into how difficult it would be to make one based on Spidermonkey in my spare time. Would you like to work on such a project?
Admin
good old days of Pascal, where you had to write some conditinal comments {$+} to be able to work with files..
Admin
The fundamental AJAX concept of using DHTML to dynamically update a web page with data fetched from a server in the background predates XMLHttpRequest and even XML considerably. Here's an article about Microsoft's Remote Scripting from 04/1998.
Admin
I get the text being sent instead of value, but only one button. Half fixed.
Admin
Maybe. I suspect things will be a little dicey trying to do this while tracking the progress of Tamarin, though.
Admin
It added quite a bit of stuff that would actually be really cool to have, if it were supported everywhere - defineSetter is one that comes to mind immediately.
Admin
As I said: A big WTF. People are still discussing about the non-existent conditional comments that they believe in so much, despite being shown that they don't exist, Microsoft told them BS, and it's actually a bug in IE being abused.
Admin
I find it funny that the Script tag allows you to put all sorts of different content types in it, but there's only what, three, that browsers will ever read?
Anyway, I was a fan of the W3C until I started dealing with the xhtml depreciations- they depreciated things without quick replacements. For example: there's no default tag that defaults to text-decoration:underline; in xhtml. To be compliant you have to use <span style='text-decoration:underline;> or or re-format cite or something.