Web Design and Build

To IE6 or not IE6, that is the question… Last updated:28 October 2011

I have now officially moved my stance on IE6 support from “must support” to “not sure”. The last two companies I’ve worked in have had IE6 as the only browser available, and I’ve been heartily fed up with sites telling me I’m retarded and lazy for not upgrading. Consequently I’ve always been quite keen on things working in IE6, or at least degrading gracefully.

Only a fifth of one percent of visitors to this site used IE6 (and even some of those were me testing) – most of them from Russia, USA and the UK if you’re interested. Some of the other sites for which I have stats, that perhaps have a more general audience (for which read less geeky…) vary between 0 and 2%.

So logic says forget IE6, but not sure I’m quite ready yet. IE6 is a pain, but it’s not like it’s that much extra effort in most cases to tame it.

Just had a look at the Save IE6 Campaign’s website. Excellent.

Views?

New online shop for Adelaide Walker Last updated:5 October 2011

Launched a full e-commerce website last month at Adelaide Walker. This represents the third stage in the evolution of this particular website which started as three static pages to provide an initial online presence about four years ago.

I’ve built it using Opencart – which I’ve not used before. Overall pretty good, the odd bit of strange coding in the version I used (1.4.9.8), and I’ve found that in order to make the site do what was required I’ve ended up compromising the upgrade path by amending the core files.

Cufon not working in Opera 11 Last updated:10 July 2011

Latest bizarre oddity.

By chance I spotted that Cufon wasn’t working on some pages on my site in Opera 11. Turns out Opera doesn’t like empty stylesheets – these pages had links that I hadn’t removed to a now defunct stylesheet. Removed the dead link and everything works again. Nothing in the stylesheet referred to anything to do with the Cufon text, but it still failed….

WordPress wrapping shortcodes with p tags Last updated:15 June 2011

Been struggling over the last day or so to stop WordPress wrapping p tags around a shortcode. I’m using Arnan de Gans Events plugin on a WordPress site for a client. One of the pages just includes this shortcode:

[events_show]

This shows a list of events. I’ve configured the plugin so each event is in its own div. And it all works fine, except WordPress insists on wrapping the whole thing in a couple of p tags, making the code invalid, producing this:

<p><div class="event>.........</div></p>

Irritating. The WP shortcode API site says “wpautop recognizes shortcode syntax and will attempt not to wrap p or br tags around shortcodes that stand alone on a line by themselves”. Nooooo.

I finally solved this by adding the following to my functions.php file:

function simonbattersby_shortcode_format($content){
$content = preg_replace('/(<p>)\s*(<div)/','<div',$content);
$content =  preg_replace('/(<\/div>)\s*(<\/p>)/', '</div>', $content);
return $content;
}

add_filter('the_content','simonbattersby_shortcode_format',11);

Points to note – the filter needs to be set with priority 11 (or higher) because otherwise the shortcode won’t have produced its output, and it’ll have no effect. All the preg_replace lines are doing is looking for a <p> tag followed by <div>, with any number of whitespaces between them, and replacing with just a <div> tag. Brute force, inelegant, but it works, and I couldn’t find any other way….

Preventing doubleclick firing two clicks with jQuery Last updated:14 November 2010

A user of my wife’s workshop page reported that they couldn’t click to expand a div – when they did it opened and then immediately closed again. Experimentation showed that in fact they were double clicking rather than single clicking – registering two click events in fact. My original code was:

$('h3 span a').click(function() {
    $(this).parent().parent().siblings(".event_hidden").slideToggle();
    return false;
});

When I started thinking about it, I couldn’t immediately see how to separate the two events – after all, a doubleclick is just two clicks, isn’t it? Fortunately jQuery provides an easy solution by using the event properties:

$('h3 span a').click(function(event) {
    if(event.detail==1){//activate on first click only to avoid hiding again on double clicks
        $(this).parent().parent().siblings(".event_hidden").slideToggle();
    }
    return false;
});

Edit 14 November 2010 Actually, problem not quite solved, since I found that IE8 and under (I don’t know about IE9) don’t recognise event.detail, and hence the code above prevents the slideToggle working entirely. Fortunately, neither does the doubleclick problem seem to affect these browsers, and hence I amended my code to:

$('h3 span a').click(function(event) {
    if(!event.detail || event.detail==1){//activate on first click only to avoid hiding again on double clicks
        $(this).parent().parent().siblings(".event_hidden").slideToggle();
    }
    return false;
});