When Windows 2000 came out, I loved it. It was the best thing out there for me, bar none, and I became very familiar with it’s inner workings, eventually studying for and obtaining an MCSE. Windows XP continued to be a very good OS, but branching into the “Home” and “Professional” versions was a bad trend. Vista took this to a new extreme. I bought a new computer last week, it came preloaded with Windows Vista Home Basic. I could have upgraded it but I chose instead to let this version introduce me to the OS. Considering that I own at least three copies of XP (and at work use at least 2 more licenses) I’m sure that they’d get their money out of me if I decided to start putting Vista on everything.
Let me tell you that this is not going to happen. Vista lasted only about an hour longer than Windows ME did on my computer, which is to say, about 1.5 hours, until I came upon an insurmountable* problem and called it quits.
*Vista’s User Accounts Control is not only annoying, but it locks out Synergy, preventing me from hitting OK unless I actually use a keyboard. The computer came with no PS2 ports and I only had PS2 keyboards, except for a horrible white-and-transparent Apple keyboard with a 9″ connector. Suffice it to say that got old quickly. Now I’m no newbie, and I know the UAC can be disabled, so I googled it, tried the solutions, and got “Access Denied”. Which is when I called it quits. Blow me, Vista.
I’d have to say that my transition to hating Microsoft came around the time of Firefox 1.0. IE at that time was some four years old and, in blatant monopolistic fashion, wasn’t being updated any more (and why should it be? It had ~97% user share! MS pulled the team off of IE and put them to work on other things). Web developers were stuck with a browser that had huge gaping holes that could mostly be worked around.
Microsoft, if you’re reading this, IE6 isn’t a horrible browser. It is merely a quirky one. IE7 is quirky too. CSS, HTML, and Javascript are unique. So when I realized as a professional web developer that there was a new boss in town, and that boss supported actual, real standards, I really started thinking about how MS doesn’t care about me. They could care less if it takes me days, weeks, and months of my time to hack up my code to support their lacking standards. Which is why they can go fuck themselves. They blew off the internet, then tried to embrace and extend it to death, and now they’re using it for their own purposes, rather than the exceedingly important public good. They personify everything that I hate about corporations.
Today, over 50% of surfers use IE6. I will have to continue developing for it for probably another four years. I’m actually getting pretty good with it, which is why today’s problem caught me off guard.
getAttribute and setAttribute allow you to check and update properties of HTML elements. You can check and set the href, the style, the align attribute, and more. But one thing you cannot set in IE6 or IE7 is the onclick attribute. It works just the same as any other attribute in every browser except for IE. Why? Pure hackery!
I spent over two hours, needed a lot of help from coworkers and my Beginning Javascript book, and finally came up with a solution that abstracts away from IE’s madness.
function updateOnclick(obj, findMe, replaceWith) {
var onclickVal = obj.getAttribute(’onclick’).toString();
if(onclickVal.match(/\{\s*(.*\s*)\s*\}/)) {
// IE will match this regexp
onclickVal = onclickVal.match(/\{\s*(.*\s*)\s*\}/)[1];
onclickVal = onclickVal.split(findMe).join(replaceWith); // or whatever you need here
obj.onclick = new Function(onclickVal);
}
else {
// Works with all non-IE browsers tested so far
obj.setAttribute(’onclick’, onclickVal.split(findMe).join(replaceWith)); // or whatever you need here
}
}
Again, sorry about the lack of indentation…
No Comments »