Getting a button element's value attribute (not innerHTML) in IE

2008-05-23 2 min read Ie Ie8 Javascript Microsoft Eddie

After spending a small part of my evening debugging Javascript in IE (which is ALWAYS a pleasure), I found out one of my errors was a mistake I had made before… trying to access button.value in IE. IE, of course, being IE, returns the innerHTML value of the button, instead of the value attribute. Last time I ran into this, I used a class instead of value, and moved on with my life. Tonight, I was feeling stubborn, and I found a better way…

target.value = target.getAttributeNode(‘value’).nodeValue;

I’m sure I’m about the millionth person to discover this, but I couldn’t find it anywhere using standard searches, so I thought I’d try to emphasize it here so others could find it. (Hopefully it’s not so common that everyone else knows it!)

At first, I used the following:

target.value = target.attributes.getNamedItem(‘value’).nodeValue;

Then I looked at Flanagan’s Javascript: The Definitive Guide (using his amazon associates link), where he states that IE implementation of the attributes array,“makes it impossible to use this feature portably.” He doesn’t mention which version of IE (this specific line of code worked in IE6, IE7, and IE8a), but I figured I’d go with the more general version.

If you read this, I hope I could save you a bit of time.

P.S. – I used IE8a’s Debugger to help. Here’s hoping they develop it further before the standard release. It’s MUCH better than flying blind, but I can’t imagine a less helpful message than specifying an object in the console, and seeing “{…}”.

My first flickr video

2008-04-27 1 min read Flickr Eddie

I’m pretty happy with Flickr’s new video service… I took this video back at the beginning of Feb, and tried to upload it to YouTube, where it was promptly rejected for being in the wrong format. I didn’t want to bother converting it, so I just forgot about it for a while. Flickr, on the otherhand, instantly uploaded and converted the file for me. All I had to do was pick the file. Since I’ve been ridiculously busy, I can’t beat the convenience factor with a stick! So enjoy!

2008-04-04 1 min read Twitter Eddie

My friend Raluca just wrote me this tweet… saying “I just found the funniest comic that someone made about @edwelker”. The scary part is that I never told her that I actually did that…

PHP and Me

2008-04-01 2 min read Programming Xslt Eddie

I just finished writing a not-so-simple, not-so-complex PHP script. First, lemme say that I had a good time with it, since it isn’t either XSLT or Portal (my workplace’s homebrew) code. It’s kinda refreshing to look outside of my multi-month project. Exciting, in fact… despite how insignificant (in the grand scheme of things) it is.

I’ve got to admit, thought, that I don’t really like PHP. I’m not going to bash PHP outright (as I’ve heard MANY people do). It is a programming language, and it certainly has it’s place. I’ve used many things written in PHP. In fact, I feel bad about the way people dismiss PHP. That said, I still don’t like it. My problem is that I feel PHP is simply too verbose. There seems to be a function for everything. It is the total opposite of Scheme, where every function is a based on a handful of core functions. I have had to deal with a number of languages in my life, and I certainly prefer languages with as little syntax as possible.

I spend a lot of time googling the functions. And then the parameters. And then the return types. And then I run across another function that is kinda like the first one that I saw, but slightly different (maybe even described as more or less efficient!) And then I have to research the return types. I’m mostly bothered by the related functions. Just give me something I can use in different ways. Don’t give me the kitchen sink and tell me to choose the faucet type.

This is the same problem that I have with XSLTs. It is a rather verbose language (which happens to usually be interspersed in XML/HTML). This makes it hard to pick-up in a hurry, and makes it unintuitive. This is important. Unintuitive. I spend a major part of my work day making sure that all of the webpages, all of the components, all of the behavior… even the URLs of my work are intuitive. So I don’t like to accept much less from the tools I work with.

To extend the analogy slightly further… I have seen that when websites are unintuitive, that said websites can fail. Is the same thing the case for programming languages?

Older posts Newer posts