- Feature Articles
- CodeSOD
-
Error'd
- Most Recent Articles
- Retry Fail
- Office Politics
- Secret Horror
- Not Impossible
- Monkeys
- Killing Time
- Hypersensitive
- Infallabella
- 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
Admin
In fact, it is up to and including IE7. Having just tested this with your code, I can say that IE7 gets the element with the name "name" rather than the one with the id "name".
It is a problem, though anyone who actually feels the need to give an element a name equal to another element's id should probably stop and make very sure he really needs to do that.
Admin
No, eval's execution context is the current one. You might be thinking about setTimeout or setInterval.
Admin
... I don't even.. I...
WTF!
Admin
Yeah, I am tired of these DOM nazis like Pilum. These kind of people love to "deprecate" (or at least criticize) something that has worked for years. They take something like HTML / JavaScript and write some stupid standard for it years after the fact. Then, with the stroke of a pen, all of our code is rendered "non-compliant" years after it was written.
The height of absurdity is that VS.NET verifies ASPX markup against some kind of XHTML "standard." All of the ASP tags fail this check, and the compiler generates bogus "errors." Some HTML-compliant markup that is not XHTML-compliant fails also. Of course, everything still WORKS fine.
Maybe there is a special little section in Hell for these people who write phony standards.
Admin
Hmmm.
I'd suggest that there be a special section of Hell reserved for:
The people who designed Javascript to begin with.
The people who think having a vendor specific implementation of Javascript is a good thing.
The people responsible for not implementing Javascript and the DOM as a plugin.
The thing I hate most about developing for web apps is dealing with browser variations. Which I why I try to do back-end stuff rather than browser oriented work.
Admin
That's why most people now do this for backwards compatibility in a standard js include file, which allows all subsequent DOM access to be written to the standard, but still work with older browsers with a dom, and degrades gracefully for others.
Admin
What else would the eval() function be for if you werent supposed to use it to run the code?
Admin
Double-escaping and unescaping is usually a bad idea, it's quite easy to forget to escape twice or unescape twice, letting trash into the page.
Admin
There is a difference between what you can do... and what you SHOULD do.
Coldfusion, for example, uses EVAL quite routinely to get around limitations in the language itself. But good PHP developers avoid it like the plague, and in many shops it's banned outright.
The question you have to ask yourself when using eval() to do something is... is there a better way to do this?
The answer, of course, is yes.
Admin
Perhaps they were trying to write cross-browser code... or at least code that would not break in non-IE browsers. document.all is an IE only construct, so maybe he got some errors in Mozilla based browsers and figured he'd just to a try/catch with an eval to prevent errors.?
Other than that... it looks completely stupid.
Admin
does that make w3c "dom nazis" as well?
document.getElementById() has been a method of DOM since Level 1 HTML spec (http://www.w3.org/TR/REC-DOM-Level-1/level-one-html.html, 1998), and in core spec since Level 2 (http://www.w3.org/TR/DOM-Level-2-Core/core.html, 2000), while document.all is just as proprietary and non-standard, and virtually obsolete, as document.layers, and unless you and/or your clients use IE4 or NS4, you don't need either
if you do web dev, especially DOM scripting, you would almost immediately see the importance for having w3c standards and recommendations just from this example alone
not sure what version of VS.NET you're using, but my built-in validator in VS 2005 doesn't trip up on server controls ... and html/xhtml validation is only useful after the page is rendered anyway; are you trying to validate the page file itself while still on the server?
as for your XHTML "standard": http://www.w3.org/TR/xhtml1/
frankly, i'm surprised you even pay attention to xhtml validation, and i'd be even more surprised if you even actively validate your pages
seriously, learn about w3c, who they are, why they and their "phony standards" are important ... otherwise stick to codebehind and .NET, and leave client side web dev for real web devs ;)
wow, talk about wtf ... i sincerely hope you're just trolling, because if you aren't, you're just creating the mess that us real web devs eventually have to clean up ... that's our hell
Admin
My guess is this is obfuscation to get around ad blockers. See also: document.write("<SCR" + "IPT>[...]");
Admin
"[W]hat's the point of assert(0 == 1) in a language that supports throw?"
There could be a couple of reasons, depending on the specifics. First, the 'assert' may be easier to modify in a debug build to log the file name and line number. Second, the code may not use exceptions anywhere else and handling them just for debug seems a bit odd. Third, the 'assert' may do some other processing and then call 'throw' anyway, so if you want the additional processing, calling 'assert' may be to your advantage.
Lastly, 'assert' clearly identifies it as debugging code, whereas 'throw' does not. This may permit certain type of optimization or evaluation bypassing in a release build. Obviously, bypassing evaluation won't help much for '0 == 1', but that might explain a general habit of using 'assert' instead of 'throw'.