I’ve had quite a frustrating day today trying to get my internet hooked up here in Korea. To finalize the connection here, you must register your computer with the company via their website. Or, at least, that’s what I’m assuming as the site is in Korean and the guy installing the internet didn’t speak much English.
Anyway, the registration site wasn’t working because when the installer dude was clicking on the menu tabs, nothing was happening. I pulled the same site up in Safari and FF3, but still, it didn’t work. Being ultra annoyed at this point, I opened Firebug and started going through the code. Here’s what the menu tab link looked like:
<a href="javascript:goMenu(1)"</a>
And the offending javascript:
function goMenu(menu) {
if(menu == 1)
location.href = "/sw5/order/wm/wm_install.jsp";
else if(menu == 2)
location.href = "/sw5/order/wm/wm_repair.jsp";
else if(menu == 3)
location.href = "/sw5/order/board/board/supportBoardList.jsp";
else if(menu == 4)
location.href = "/sw5/order/board/bbsDown/supportFileList.jsp";
else if(menu == 5)
location.href = "/sw5/order/board/bbsError/supportErrorList.jsp";
}
Technically, there’s nothing wrong with the javascript. It should work fine, but since there were some errors in some of the other javascript, the whole javascript file didn’t parse correctly, therefore, this particular function didn’t make its way to the javascript interpreter in the browser (unless your browser was IE7 for some reason).
The bigger question of course is why would you ever program like this? Does the person who wrote this have no idea what an anchor tag does? Why would he/she not choose to just put the URL into the href of the anchor tag? I mean, this is pretty fundamental here. If you ask anyone who’s even attempted to make a website for more than a day, I’m sure they could tell you how to make an anchor tag. On top of that, a it would be better to at least explicitly use the window object and call window.location.href. But I guess, if you don’t know how an anchor tag works, why bother with doing javascript correctly.
So, curious as to what else the programmers of this site could possibly do, I saw two methods defined that looked kind of funny that are probably the reason the javascript file wasn’t interpreted correctly.
function document.oncontextmenu() {....}
function window.onload() {....}
So, the programmer isn’t trying to call the document.oncontextmenu or window.onload functions, the programmer is trying to define these functions. I can’t really fathom why you would ever, ever want to do this. Of course, most normal javascript parsers think that you are calling the function window.onload instead of defining a method called ‘window.onload()’, so the javascript bombs out. I guess the IE parser is a little more lenient and probably silently ignores it. But again, it just baffles my why anyone would write this and that code like this made it to the registration site of one of the largest internet providers in Korea, which happens to be the most wired country in the world.
How are we teaching people to make websites these days, anyway?
