Add HTML Elements to XUL Addons
I've been working on a new addon at Mozilla which isn't anywhere near finished so I wont bother telling you what it's meant to do...because it could change at any moment. Since this is my first real addon, it's been a struggle, but that's a good thing -- it means I'm learning a ton. One problem I ran into was trying to get a checkbox (INPUT
) element within the addon via JavaScript -- nothing was displaying.
After a bit of research and guesswork, I figured out what I was doing wrong -- I was using the wrong document
method to create the element:
var input = document.createElementNS("http://www.w3.org/1999/xhtml", "input");
Using document.createElementNS
with the proper namespace resulted in my checkbox displaying in all of its glory. It's beautiful square, checked glory. Firefox addons can be created in a number of ways so if you're looking to create your own and you aren't seeing HTML elements correctly, keep this solution in mind!
I get asked loads of questions every day but I'm always surprised that they're rarely questions about code or even tech -- many of the questions I get are more about non-dev stuff like what my office is like, what software I use, and oftentimes...
One of my favorite social APIs was the Open Graph API adopted by Facebook. Adding just a few META tags to each page allowed links to my article to be styled and presented the way I wanted them to, giving me a bit of control...
We've always been able to create links with protocols other than the usual HTTP, like mailto, skype, irc ,and more; they're an excellent convenience to visitors. With mobile phone browsers having become infinitely more usable, we can now extend that convenience to phone numbers:
The tel
...
Modern browsers are nice in that they allow you to style some odd properties. Heck, one of the most popular posts on this blog is HTML5 Placeholder Styling with CSS, a tiny but useful task. Did you know you can also restyle the textarea resizer in WebKit...
Reminded me of my initial days with JavaScript David! I also made the same namespace errors and then wondered for hours, what went wrong!