How to Detect a Touch Device Using JavaScript

A while back I had to make a navigation menu which played a sound when you moused over the various menu points.

The problem was, that this feature didn’t play nicely with touch devices, as they don’t really have a concept of hover.

What happened instead was that the sound would play when the user selected one of the menu points, but would get cut off as the new page loaded – eurgh!

More …

Simple JavaScript Debugging with Chrome's Console

All too often of late, I have seen people having trouble trying to debug some JavaScript or other.

Some were stumped by the white screen of death which confronted them the minute their script failed silently, whilst others were trying to debug their program using an alert dialogue box (a truly tedious process).

Well, good news it at hand. There is another, more efficient way to do things – with the console.

More …

PHP – header('Location: ...') not working in MAMP

Recently, I was trying to help someone build a simple contact form in PHP.

This person was running everything locally on a MAMP server (Macintosh, Apache, Mysql and PHP) and everything was going swimmingly until we ran into a strange issue: PHP’s header('Location: ...') wasn’t working as expected. In fact, it wasn’t working at all.

This is how we solved the problem.

More …

Display Your WordPress Contact Form in a Lightbox

Recently, a client asked me to have their contact form display in a Lightbox (as opposed to on a separate page). I happily implemented this for them and the end result looked pretty snazzy, so I thought I’d write up how I did it.

More …

Using Cookies with jQuery to Make a Simple Style Switcher

Short for HyperText Transfer Protocol, HTTP is the underlying protocol of the World Wide Web. It is used when a browser requests a web page from a server and it is used when the server responds to the browser’s request. HTTP is also stateless, which means that once a server has sent a page to a browser, it forgets having done so straight away. This can be a problem, for example, if a user has identified themselves in order to access protected pages, or if a user wants to customize some aspect of a website, as the server simply cannot remember a thing about it!

More …

How to Run a Batch File as Admin in Windows 7

This is quite a handy tip I picked up this week when I had a Windows batch file which I needed to run with administrator privileges.

Of course, you can find the file, right click it, select Run as Administrator and do it that way, but if you need to run this file more than a few times, that soon gets to be a pain in the neck.

More …

How to Pass Parameters to Your WordPress Templates

I currently find myself in the middle of redesigning this site, as I want to move away from the generic WordPress theme to something a little more individual. That my new design should be responsive was a no-brainer, but this time round I decided to try something new (for me, at least) and that was to design for mobile first.

More …

Making Lightbox Work in IE9

I’m a big fan of Lokesh Dhakar’s Lightbox script, which is an elegant and easy to use method of displaying images against a darkened background on a web page. I’ve used this script quite heavily in the past, so I was somewhat alarmed when reviewing some of my old projects, to observe that it was broken in Internet Explorer 9.

More …