A LIST Apart: For People Who Make Websites

No. 269

Discuss: Text-Resize Detection

Pages

| 1 | 2 | 3 | next »

1 Discuss

Use this space to discuss the different options of this solution or to brag about great implementations. You can also use this spot to ask for solutions and liase with other developers willing to implement them. I will be busy over the next three days training some people in sunny Munich, but Lawrence will keep an eye on what is happening.

posted at 11:22 am on September 12, 2006 by Christian Heilmann

2 jQuery Plugin

I created a plugin, jQEm a few weeks back that adds similar functionality to the jQuery library.

I found that with Internet Explorer you can use setExpression to avoid having to inefficiently poll for changes periodically.

posted at 11:31 am on September 12, 2006 by Dave Cardwell

3 Another JavaScript implementation

It shouldn’t be used as an excuse for developers to not design sites properly. Not everyone uses JavaScript.

That said, it’s a good solution to a common problem. Obviously you need a bit of JavaScript knowledge already. Out of interest, why didn’t you move all the JavaScript to external files?

posted at 11:33 am on September 12, 2006 by Adam Craven

4 Properly designed pages

Adam, actually I think it works the other way around. A lot of designers I met so far argued that they just cannot use resizable fonts (not realising that there is no way around it) as they will kill the layout sooner or later. This is a solution to counteract that. If you also only apply a stylesheet that uses a layout that doesn’t work with large fonts via JavaScript it is pretty safe. Users without JS get a fully resizable layout, others get one that works and switches.

posted at 11:42 am on September 12, 2006 by Christian Heilmann

5 Worthwhile Javascript

It shouldn’t be used as an excuse for developers to not design sites properly. Not everyone uses JavaScript

I don’t agree that this does equate to “not designing sites properly”. It is perfectly possible, maybe even very easy, to design a site that functions at all text sizes, but may not look all that good at the extremes of the scale.

Using Javascript to improve the performance of the page is perfectly acceptable – as long as the page still functions OK when JS is not enabled.

posted at 11:42 am on September 12, 2006 by Stephen Down

6 why not external?

Adam, I left the initialisation javascript within the html file as I thought it would make the examples clearer. On production, it would probably be best to have it within an external file

posted at 11:50 am on September 12, 2006 by Lawrence Carvalho

7 original need..

Incidentally, my original need for such a script came about not from a site design issue but from a component/widget I was working on where I needed to update the widget if the textsize was larger than normal.

posted at 11:53 am on September 12, 2006 by Lawrence Carvalho

8 Excellent!

Thanks again for another great ALA article.

As ‘designers’ are, to a greater and greater extent, actually designing web sites the need to fix broken layouts due to large font sizes shouldn’t be much of an issue.

Personally, I feel comfortable with designing a layout such that nothing breaks/overlaps for any of IE’s range of font sizes (a range which covers enough but doesn’t generally extend to silly large sizes). If a FireFox user wants to supersize the text then so be it.

However, buttons containing a fair amount of text are often annoying as I’ve never seen a browser that will maintain a fixed button size and wrap the text accordingly. Merely having the option, through text-resize detection and a bit of JS, to get a button to grow only vertically but not horizonally would be quite nice and is something I’ll have to play with some time soon.

posted at 12:44 pm on September 12, 2006 by Jon Cram

9 Almost

It doesn’t work properly in Opera. A pop-up message occurs every time you zoom in an extra 20%! So at 110%, nothing. But press + again to reach 120% zoom and the pop-up tells me the font size has decreased by 1px. This happens every 20%. Therefore, the script cannot be used as it stands – unless you hide it from Opera users.

posted at 03:30 pm on September 12, 2006 by Chris Hester

10 Opera

Chris, Opera and IE 7 do not perform actually resizing of the text. These browsers zoom everything on the page so the actual size of the text stays the same. So for these browers detecting text size changes is not very useful. However it is useful to know the size of the text at the point of load (to detect users who need larger fonts for whatever reason – health or hi-res screens) which it does report correctly though.

The article does allude to this behaviour for Opera and IE7 but perhaps we should have made it clearer.

Thanks for posting the error in reporting the -1px decrepancy. Obviously this shouldn’t happen and I’ll take a look (didn’t notice this in testing). The event shouldn’t really fire for Opera and IE 7 but because of the bug, it thinks there is a font size change and fires.

posted at 04:34 pm on September 12, 2006 by Lawrence Carvalho

Pages

| 1 | 2 | 3 | next »

Discussion Closed

New comments are not being accepted, but you are welcome to explore what people said before we closed the door.