Alexa Widget
Alexa Widget
2005-12-17 03:18:40 by Andrew Hitchcock G+
I just finished my second widget. I had lots of trouble coming up with an idea... I wanted to make a Homeland Security terror meter widget (like I have for Dashboard), but I don't think I can use the images from that widget and I don't have the artistic ability to create my own. However, I eventually came up with an appropriate idea: Alexa Widget! If you have the widget point to a URL (instead of hosting the code yourself), it'll pass the user preferences to that URL using a GET. The Alexa graphs are generated through variables in the GET request. I had hoped that it would be as easy as defining user preferences with the names that Alexa takes, and then just pointing it to the Alexa URL. However, the widget API prefixes "up_" before the variable names, ruining that idea. However, it wasn't hard to generate the URL by hand and then post an img link into the <div>. The biggest hurdle was trying to figure out why the browser was claiming that the <div> didn't have any properties (namely the innerHTML property). I tried using Mozilla's javascript debugger, but that was very unfriendly and didn't really help me. I eventually realized that the javascript was being called before the <div> was being rendered, so the browser didn't know about it yet. I don't have a lot of experience with Javascript, so I'm learning all these little quirks as I go. I don't really like Javascript, it is kind of a pain to use, so I'm gaining much respect for the Google developers that created Gmail and Maps.
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.