This page has moved to
http://www.superluminal.com/dave/weblog/archives/2003_01_28.html
You will be redirected to that page in 10 seconds.
New RSS feed at
http://www.superluminal.com/dave/weblog/index.xml
Holons, nothing but holons.
Tuesday, January 28, 2003
« Dynamically Extending JavaScript »
Dynamically extending APIs.
Usually when a cool Python script comes along, I'm thinking if Javascript can do this too. It almost always can. Yet there are so few Javascript fans that I can't help but showing what Javascript can do to anybody that will listen.
Today Mark Pilgrim shows how to dynamically extend APIs with Python. Javascript can do this too, it's almost trivial even. At Q42 we use this a lot in Mozilla to extend the DOM with some of the more useful Internet Explorer features. (We would like to be able to do this the other way around, but IE's DOM is not implemented in a very Javascript compatible way.) Here's one example how to extend the DOM to support the selectSingleNode method. Note that after the code has executed, all XML and HTML nodes support the method.
Count me as a fan (even more so if I can ever get the Mozilla JavaScript debugger to work). I love being able to do this sort of thing.