Scaling websites to mobile screen sizes

Useful bit of info that it took me a little while to find – there’s a new meta tag “viewport” that you have to know about.

The short story
Take this and play with it – note width can also be a pixel value, just replace with a number:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

The long story

So if you had a nice, simple website with a heading and some text you would expect the mobile browser to find a sensible scaling for that wouldn’t you? Nope – the left is my artist’s rendition of what happens if you just have some HTML and you don’t specify any sizing information at all (and you haven’t got the above meta tag either).

OK, you think, it must have some sort of width that it expects the html element to be – let’s resize that (or body or something) so that we only have 320px worth of content. What happens then?

Well you get this – the mobile browser is basically wasting a lot of space.

This is because mobile browsers are assuming that your website needs somewhere between 800-1000px (depending on device) to display properly, it then renders the page according to that width and then does a pixel-by-pixel scale down so that all the page comes up on the screen. But tiny.

Now when you take out the CSS forcing body / html / top-level div width and replace with a meta viewport tag saying that your site has been designed for (say) 320pixels or to be fluid at small resolutions (device-width) it won’t need to scale it’s calculated website down so far, or at all. And you get the result you’re looking for lovingly rendered by myself to the left.

There’s a very detailed breakdown of what’s going on at quirksmode.

Seeing Russell Howard’s Good News live recording

Brilliant seats to see Russell Howard’s Good News last night from TVrecordings.com – tickets really go to the fastest responders to the newsletter as far as I can tell. Update 2013: I’ve not had as many e-mails from them recently, you may have to follow them on Twitter now.

I thought I’d write up the format of the show a little bit in case anyone ever searches for it and wants advice on when to arrive and stuff – because I’ve previously tried to get there and I was turned away.

The doors say 6, but we weren’t sat in the studio until gone 7 – there was a lot of outside waiting. There are nearby shops – people had MacDonald’s, Subways, Costa Coffee stuff.

The seats we got were in no way linked to when we arrived – we were two-thirds of the way back in the queue but were seated in the second row – although quite a bit off to the right so  I suppose there were bits of the show we didn’t really get to see.

There is an audience reaction camera which is on the right hand side of the audience as you look at the stage (i.e. where I was). The boom camera (jig?) is also on this side, so it doesn’t really get any shots of you (you’re beneath it).

Outside of half term, I arrived at 4:45 and I reckon they were turning people away at 5pm. The previous time I went it was half term and it looked like you had to arrive really early to get in.

The sticker person was there by that point and not particularly happy that people had popped off to the shops so best wait until you’ve got your stickers.

They prefer you to print your tickets out but it is possible to show them on your phone if you let them know you’re going to do that in advance.

Toilets impossible during the show but they are available while you’re queueing – go to the front of the queue and follow the road to studios.

If you have travelled a long way and you didn’t get in, you might ask them for priority tickets as it sounded like some of those holding priority had done that.

Running order: Run through of the show. Mystery guest. Mystery guest callbacks. Stand up. Callbacks. Trails.

Russell Howard is a very funny man and it’s really nice to see a performer interacting with audience when possible – his talents as a compere work really well for this show and it was good to hear him make NSF-TV jokes up and share them with the audience. Then back up and record one that can be broadcasted. I suppose you get that sense from the odd “this won’t be on telly” comment on the TV shows but there’s quite a bit more of that than is shown.

Geeking out with a speedometer on a train

(today = about two months ago)

My train from London was cancelled today so I had to catch the Swindon train and change. Out of Paddington I noticed we seemed to be hopping it something fierce. Twenty minutes, a new app, and a change at Reading later I had my answer – the first train was going at 120mph (class 125, train fans) and the usual Oxford service at 85mph (class 165).

For those who were never train spotters you might not have noticed that the Oxford-London fast train is served by a combination of 165s and 125s but the timetable is the same for both. Back of the envelope calculations suggest that there could be a 45 minute service into London during peak times (when they tend to use the longer 125s) – how convenient would that be, eh?

Automatically submitting a form with javascript – don’t break the back button!

There’s a problem with automatically submitting a form with javascript – by just calling the submit() method – you break the back button. We can use the fact that browsers remember form values to prevent this from happening.

<input type='hidden' id='submitted' name='submitted' value=''>
<script>
if (document.getElementById('submitted').value == '') {
document.getElementById('submitted').value = 'yes';
document.getElementById('wp_form').submit();
}
</script>

UPDATE: Forgot to test in IE. This doesn’t work in IE6 at least, but I could do with fixing the code so look for updates.

Customer names vs. customer numbers

I’ve noticed over the past couple of weeks that the sales and service teams almost always refer to customers by their names instead of their customer id.

Of course, we’ve moved the search facility for surnames out of the way but judging by how often it’s used we should bring it front and centre and add an index on that column. We should even produce a search-as-you-type style interface for it as most surnames do bring up a fair few choices.

I can only think it’s a good thing that the customer-facing teams think of the customers by names rather than numbers and we should remember that not everyone thinks like a techie. We’ve bandied around the idea of letting customers upload photos for their account and perhaps displaying these in the CMS would re-inforce the concept that there are people behind the list of numbers and settings. Even more useful, perhaps, is finding a way to put our service and sales teams photos in front of the users – reminding them that they are also talking to a person.