Menu

Snippets

Yet another programmer blogging about code

Posts Tagged ‘javascript’

Add custom JavaScript actions to wp-e-commerce cart updates

Wednesday, February 22nd, 2012

I just stared in horror wonder at the wp-e-commerce script that handles cart updates. Wow. Just… wow. Forget any thought of nicely hooking into that to add some extra client-side actions, it’s a mess and looks like it will probably get worse before it gets better. But fortunately, there is another way.

Make CSS drop-down menus work on touch devices

Monday, February 6th, 2012

CSS drop-down menus are very popular on sites with a hierarchy of pages. They let you get to where you want to go without having to navigate the pages in that hierarchy. But pure-CSS menus suffer a problem: touch devices often can’t show the drop-down, because they don’t have “hover” and clicking on the top level link goes there. This snippet offers a way around that.

Internet Explorer 7 and dynamically created form inputs

Wednesday, January 25th, 2012

Apparently, Internet Explorer 7 is stupid. I mean, it lets you create a form input element dynamically, and add it to a form, but the form doesn’t know it by name. And I only just found this out!

Feature sniffing Internet Explorer

Monday, October 3rd, 2011

Pretty much all web developers should know by now that browser sniffing is evil. If you don’t know why, you should definitely read Richard Cornford’s excellent treatise Browser Detection (and What to Do Instead). Feature detection, where you look for the specific feature you want to use, is much safer; taken to the extreme, it can end up like the rather clever Modernizr project. But what if you really do just want to know if your code has the misfortune to be running on IE7?

Telling CSS3PIE about dynamic elements

Thursday, September 22nd, 2011

I love CSS3PIE. I love that I can make use of some of the CSS3 niceties like rounded corners and box shadow, and even IE7 and IE8 can keep up with the more modern browsers and not look too shabby. But if you’re adding or moving elements around on your page dynamically, e.g. changing something from display:block to display:none and back, sometimes PIE can’t keep up and leaves a box shadow in a strange place.

Drawers for GNOME 3 gnome-shell

Monday, June 13th, 2011

After upgrading my computer from Fedora 14 to Fedora 15 recently, I’m getting used to the new world of GNOME 3 and the GNOME Shell. I think I probably like it. Mostly. But it’s missing one big thing that I really loved in GNOME 2: drawers!

Autocomplete in WordPress plugin admin

Tuesday, April 19th, 2011

I just had to find a way to add autocomplete to an admin screen for a WordPress plugin I’m writing. Although a few pieces of jQuery UI are bundled into the WordPress distribution, that doesn’t include jQuery UI autocomplete. But on the way to investigating how to drop that into my plugin, I discovered that WordPress does bundle in a similar, simpler plugin called jquery.suggest.

CSS3 linear gradients and Internet Explorer

Saturday, April 16th, 2011

CSS3 has been tempting me with linear gradients for a while now. They don’t work in Internet Explorer, but there are ways and means with a little script magic. Now that Opera has finally joined the party, I figured it was time to ditch those ever pervasive linear gradient background images and start using CSS3 for linear gradients. But it’s not all rosy, especially when you need to position your background.

Internet Explorer CSS hacks with JavaScript

Friday, April 15th, 2011

Sometimes it’s just easier to write a quick hack to get the job done. This is one of those times.

SWMBO, the CSS guru in the house, quite rightly wants to use the :before and :after pseudo-elements to add some style to a website, in a way that will make it easy for the client to add content without struggling with keeping the format consistent. That’s easy enough in Firefox, Safari, Chrome, Opera, even Internet Explorer 8 and 9… but not Internet Explorer 6 or 7.

Calling JavaScript from VBScript

Tuesday, March 22nd, 2011

I’ve been working on a Classic ASP / VBScript website recently, so I have been brushing up against the limitations of VBScript again. Not hard limitations, like “you can’t do that”, just inconveniences like… no sort for you!

Rather than dust off my old copy of a sort algorithm, I figured the easiest way, and the path to best performance, would be to just…