| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
if(!isFirstComment()){
location.href="wtf.htm"; } |
|
That must be the very definition of facepalm code.
|
|
if(!user_owns_a_computer()) return false;
return true; |
|
Wow, I don't normally comment, but that made me say "W T F" (as separate letters!) out loud...
|
Re: Bulletproof JavaScript Detection
2009-03-16 09:17
•
by
aggle-rithm
|
Oops, I just realized this is badly flawed code. Should be: return using_a_computer(); Implementation: function using_a_computer() { switch(get_hardware_type()) { case(COMPUTER) return true; case(MICROWAVE) return false; case(ANSWERING_MACHINE) return false; case(BATTERY_OPERATED_MARITAL_AID) return false; } } No, I'm not giving you the implementation for get_hardware_type(). Do I have to do everything? |
Re: Bulletproof JavaScript Detection
2009-03-16 09:20
•
by
Not THAT Alex
(unregistered)
|
|
Schodinger-Oriented Programming
(CAPTCHA:appellatio. Who is going to protect us?) |
Re: Bulletproof JavaScript Detection
2009-03-16 09:26
•
by
Shipment of Fail
(unregistered)
|
|
I suppose this is the Web 2.0 reinvention of <noscript>.
|
Re: Bulletproof JavaScript Detection
2009-03-16 09:29
•
by
Friendly Neighborhood QA
(unregistered)
|
Your code submission lacks (A) the critical "FOR CASE" construct (B) the following "computer equipment" type case:
Please correct deficiencies and re-submit for code re-audit per Consolidated Process Work Instructions SWE-15893-122, QE-5613-123, and VTE-1348-992 within 5 working days to avoid implementation scheduling variance. |
Re: Bulletproof JavaScript Detection
2009-03-16 09:35
•
by
Another Andrew
(unregistered)
|
|
function validateSettings(){
if(!javascriptEnabled()){ // << Armageddon here if user enables javascript just in time location.href="no_js.htm"; } } |
|
This somehow reminds me of Quietust's signature (no, not signature guy, the one about the note).
|
10 Reasons why your coding-slaves sucks
2009-03-16 09:37
•
by
Tempura
(unregistered)
|
|
1) They appear on thedailywtf.com
10) They appear on thedailywtf.com, because they made a wtf failure. |
Re: Bulletproof JavaScript Detection
2009-03-16 09:39
•
by
Quietust
|
For the benefit of others, that would be "P.S. If you don't get this note, let me know and I'll write you another." (which is a quote from a The Three Stooges short). |
|
Original dev: "Well, it works on my computer!"
|
Re: Bulletproof JavaScript Detection
2009-03-16 09:50
•
by
kalleguld
(unregistered)
|
There really is only one answer |
Re: Bulletproof JavaScript Detection
2009-03-16 09:55
•
by
ih8u
(unregistered)
|
It reminds me of a time when email went down at a reasonably large company I used to work for. We were told to log off our email clients and wait until further notice to log back in -- or we'd wreck the system and end life on earth. Much later in the day, we received word from the boss that it was ok to check email again and found a message from the admins that said something like "email works now. you can log back in. kthx". |
|
Omg... ontzettende prutsers.
|
|
What's the most disturbing, that junior dev was never checked on, or that senior dev codes like that?
|
Re: Bulletproof JavaScript Detection
2009-03-16 10:03
•
by
Brompot
(unregistered)
|
Here we send and email, alert the receiver by SMS, ICQ them to check their phone and walk by to tell them they're wanted on ICQ. Just in case some medium fails. |
|
So this is why the stock market crashed
|
Re: Bulletproof JavaScript Detection
2009-03-16 10:08
•
by
Devilfish
(unregistered)
|
|
I can't decide whether I should comment on this WTF or knock myself unconscious over it.
So, if you don't see this comment, I've chosen the latter, so please call an ambulance. |
Re: Bulletproof JavaScript Detection
2009-03-16 10:11
•
by
BeOS easter eggs
(unregistered)
|
|
http://www.eeggs.com/items/15121.html
|
Re: Bulletproof JavaScript Detection
2009-03-16 10:13
•
by
aggle-rithm
|
Your rejection of my code has been rejected. If you would like to appeal this rejection, please fill out form 1080SWBS9 and file it under "Q" in the file cabinet of your choice. Thank you. |
Re: Bulletproof JavaScript Detection
2009-03-16 10:15
•
by
aggle-rithm
|
This is exactly the sort of code I dream about at night. Night after night. Sometimes, I wish I could have my old brain back... |
Re: Bulletproof JavaScript Detection
2009-03-16 10:18
•
by
DOA
|
Quoted for awesomeness. |
|
so what is a good way to check for JS detection...
|
Re: Bulletproof JavaScript Detection
2009-03-16 10:26
•
by
Edward Royce
(unregistered)
|
|
Hmmm.
I don't see what the problem is. If Javascript is not enabled then the function won't operate. Thus success! Sooooo. What's yer problem then? *LAUGH* |
|
Erm... Don't do it. Graceful degradation / progressive enhancement FTW
|
Re: Bulletproof JavaScript Detection
2009-03-16 10:28
•
by
Anonymous
(unregistered)
|
|
The simplest way is to present the non-javascript version and turn on javascript functionality using javascript. If the javascript page is very different you may redirect the user with javascript.
The best way is to make sure that the page works without javascript so you don't really care if the user has javascript enabled or not. |
Re: Bulletproof JavaScript Detection
2009-03-16 10:29
•
by
JuanCarlosII
(unregistered)
|
|
<noscript>
<script type="text/javascript"> location.href = 'no_js.htm'; </script> </noscript> ... obviously. |
|
Heh, well, it didn't make it past me into general testing, but I had something similar here.
The developers were using JavaScript to hide the "You must enable Javascript" message, but the users were complaining that the message would sometimes flash on screen as the page loaded. So what did the developers do? Flip the logic of course (to use Javascript to make the message appear if Javascript was turned off). More disturbing (yes, it gets worse) is that I suggested using <noscript> BEFORE they made the change, and again afterwards... but it took 2 more tries for them to actually listen. All of which was, of course, after I had to convince my boss that the <noscript> tag wasn't some kind of personal hack that was just an excuse for an ego trip for me. Disclaimer: I wrote none of this code, nor was I around when it was written. Nor will I be around for more fun and games after I leave for greener (and saner) pastures on Friday. |
Re: Bulletproof JavaScript Detection
2009-03-16 10:46
•
by
Leo
(unregistered)
|
ICQ? Is it still 1999 where you work? |
Re: Bulletproof JavaScript Detection
2009-03-16 10:48
•
by
Edward Royce
(unregistered)
|
Have the default version be the Javascript disabled and then have a <script> tag that redirects the browser to the Javascript enabled version. <script> window.location = "http://www.myuglywebsite.com/js_enabled.php"; </script> If Javascript = off then you're ok. If Javascript = on then the browser gets redirected. *shrug* that's what I know. Is there a better method? |
Re: Bulletproof JavaScript Detection
2009-03-16 10:51
•
by
FriedDan
|
For those who have missed the references. The <noscript> tag. Content inside this tag is only shown if JavaScript is turned off or if the browser does not support it. http://www.w3schools.com/TAGS/tag_noscript.asp |
Re: Bulletproof JavaScript Detection
2009-03-16 10:56
•
by
John
(unregistered)
|
Ouch, almost wrote a serious reply to that one. I did try to add a method to unset the content attribute in a meta tag, but it that doesn't work as the browser's already started the timer to refresh/redirect the page (even if I extend the delay). <meta id='metaRefresh' http-equiv='refresh' content='1;url=http://www.google.com' /> <script type='text/javascript'>//<![CDATA[ document.getElementById('metaRefresh').content = null; //]]></script> Removing the tag from the head doesn't work either. |
Re: Bulletproof JavaScript Detection
2009-03-16 10:56
•
by
Sashlik
(unregistered)
|
We love ICQ here in Russia, and use it widely :) |
Re: Bulletproof JavaScript Detection
2009-03-16 11:03
•
by
John
(unregistered)
|
But it's not the way management wanted it. How are you going to explain to your starving children that there's no food as daddy ignored his superiors. |
Re: Bulletproof JavaScript Detection
2009-03-16 11:05
•
by
Beldar the Phantom Replier
(unregistered)
|
I guess someone has been missing out on classic articles. |
Re: Bulletproof JavaScript Detection
2009-03-16 11:08
•
by
RBoy
(unregistered)
|
In Soviet Russia, you don't seek me, ICQ! I'll be here all week, try the veal. |
Re: Bulletproof JavaScript Detection
2009-03-16 11:12
•
by
FriedDan
|
I dunno, even my "superior" caved after the developers screwed it up a few times. And then there's the added bonus of telling the "superior" that he has to explain to his boss about that pesky 2 weeks notice that helps a lot. |
Re: Bulletproof JavaScript Detection
2009-03-16 11:19
•
by
Ketchup
(unregistered)
|
Nope, here in Russia we hate ICQ, it blocks alternative open-source clients and russian IP. Now we switching to jabber, including Google Talk. |
Re: Bulletproof JavaScript Detection
2009-03-16 11:20
•
by
John
(unregistered)
|
Hmm, I'd forgotten about that one. If that's a reference to my solution being overcomplicated, I disagree. It was the first solution I came up with that allowed the page to be redirected when Javascript is disabled. Other methods are: Redirecting to a page when javascript is enabled: not ideal because the majority of users enable javacript (as long as we're talking about a non-techie website). Using javascript to overwrite an element describing why javascript is needed can cause an annoying flicker when the page is loading, so again not ideal. That said, most my pages use javascript, but will still work if javascript is disabled as the effects are replicated by a post or get. Bit tedious but does mean the site is fast for javascript lovers and works for javascript haters. |
|
This WTF wins the intertubes.
|
Re: Bulletproof JavaScript Detection
2009-03-16 11:25
•
by
Code Dependent
|
Wouldn't that more accurately be, BATTERY_OPERATED_BACHELORETTE_AID? |
Re: Bulletproof JavaScript Detection
2009-03-16 11:30
•
by
Anon
(unregistered)
|
Someone's never been married for 5+ years... |
Re: Bulletproof JavaScript Detection
2009-03-16 11:43
•
by
justsomedude
(unregistered)
|
|
Gems like this make it easy for me to brush off the stigmas surronding VB. When it comes to code quality, which language is used seems significantly less important than the skill of the developers using them ;-)
|
Re: Bulletproof JavaScript Detection
2009-03-16 11:44
•
by
mort8104
(unregistered)
|
|
<%
/** * a bulletproof test for the presence of a running computer * NOTE: also requires a browser, a connection to the Apache instance, and a user. **/ function UsingComputer() { return true; } switch (UsingComputer) { case true: echo 'congratulations, you appear to be using a computer'; break; default: echo 'oh dear, for this code to run you need a computer'; break; } %> |
Re: Bulletproof JavaScript Detection
2009-03-16 11:47
•
by
Edward Royce
(unregistered)
|
|
Well.
"Redirecting to a page when javascript is enabled: not ideal because the majority of users enable javacript (as long as we're talking about a non-techie website). " Sure it's not ideal. What would be ideal is if the browser reported to the server in a variable the state of Javascript on/off and perhaps a type or version number or some such thing. Frankly the whole issue of Javascript on/off, issues with differences in functions, objects, DOM and other bullcrap makes writing web apps annoying at best and vastly irritating at worst. No wonder so many people are doing sites in flash. |
Re: Bulletproof JavaScript Detection
2009-03-16 11:49
•
by
Edward Royce
(unregistered)
|
Hell if you think this stuff is amusing you see Google the fools who want to use Javascript as their language for doing -server side- coding. *shrug* what can I say. |
Re: Bulletproof JavaScript Detection
2009-03-16 11:50
•
by
LHC
(unregistered)
|
I thought that was a typo - battery operated nunchakas!! |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |