Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think there's some fairly clever stuff going on. The page source is pretty simple (yes, I'm sure we've ALL looked at it at one point). Take this function for instance:

function byId(id) { return document.getElementById(id); }

My guess is that the function body is rendered differently for different browsers. If that's true, it's a clever way of doing cross browser Javascript.



document.getElementById is generally pretty portable across browsers.

And another clever way of doing cross-browser JavaScript is just to use a mature JS library like Prototype or JQuery. They all give you byId for free, in the form of the $ function.


I'm with you there - prototype is first class stuff. I wasn't sure if getElementById was supported by Opera or Safari. If it is, it looks like byId() is good way to save some typing.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: