Java? JavaScript? Is there a difference?



  • I came across a site with an intro page the other day. That's already a WTF right there, but I'm not going to rant about that right now. The interesting thing is that this intro page is supposed to detect whether or not you have javascript enabled. Here is the code they use to accomplish this feat:

     

    <font face="courier"><SCRIPT LANGUAGE="JavaScript">

    if (navigator.javaEnabled())
    window.location = "enter.htm";
    else
    window.location = "nojava.htm";

    </script></font>

     

    So, if you don't have javascript enabled, you're redirected to... er... no, wait. :-P 



  • Ummm... this code appears to do exactly what it claims to be doing-- test whether Java is enabled. If it was a test for Javascript, the code block would just contain an unconditional redirect.



  • Are you [i]sure[/i] that maybe they aren't [i]actually[/i] checking for Java support? Because that's what it looks like to me.

    From http://developer.mozilla.org/en/docs/DOM:window.navigator.javaEnabled

    This method indicates whether the current browser is Java-enabled or not.


  • The real WTF is why anyone would want to test to see whether or not a box is checked in your preferences.


    (Yes, I'm running Firefox. Yes, it returns true on my system when the "Enable Java" checkbox is checked, and false if it's not. No, my browser doesn't have the Java plugin installed.) 



  • Yes, I know it actually checks for java, not javascript, hence the title. If you have java disabled, you will be redirected to a page telling you that you need to have javascript enabled. The webdesigner obviously doesn't know the difference between javascript and java, that's my point.



  • WHAT page that tells you Javascipt is disabled?? You simply posted that Javascript code... and the code is right...

    Where is the WTF?

    You can't just infer that we all know what the page looks like that it redirects you to...


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.