Here are the results of my research into the firing of the resize event in nine mobile browsers.
Resizing takes place all the time, but we have to distinguish between the visual viewport, the layout viewport, and the HTML element. All three may be resized by user actions. The question is whether their resizing triggers a resize event.
See this page for an explanation of the visual and layout viewports.
The layout viewport’s dimensions are changed when the contents of the meta viewport tag are changed. This is an easy use case: all browsers that allow the meta viewport tag to be changed, fire a resize event when that happens.
Opera, Safari, Android, Dolfin, Palm, and MeeGo allow the change and fire the resize event. The other browsers do not allow the meta viewport tag to be changed.
The HTML element’s dimensions are changed when extra content is added to the page that stretches up the element, or when a draggable layer is dragged beyond the edge of the HTML element.
Opera, Safari, Dolfin, MeeGo, and Firefox fire a resize event when that happens, except that Firefox (and maybe Opera) does not fire a resize event when the vertical dimensions of the HTML element change.
Android, BlackBerry, Symbian, and Palm do not fire a resize event when the HTML element’s dimensions are changed. As far as I’m concerned this is a bug.
Changes to the visual viewport are a problem. I tested orientationchange, zoom, and showing and hiding the browser bar and the software keyboard. All these actions change the dimensions of the visual viewport.
The fundamental question is whether the resize event should fire at all. My current take is that it should.
Untestable means that the browser does not support the test case at all. For instance, Palm and Symbian don’t support the touch events, so I can’t drag a layer around to see if a resize event fires.
My test page doesn’t work in my Opera Mobile 11.50, which is the most recent mobile build. (It does work in 11.60 on desktop.) Fortunately a reader’s Opera Mobile did work, and he gave me these screenshots to determine Opera’s score.
| Property | Opera Mobile | Safari | Android | Black |
Dolfin | Symbian | Palm | MeeGo | Firefox | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Presto | WebKit | Gecko | |||||||||||||||||
| Visual viewport | |||||||||||||||||||
|
Orientation change
|
Yes | Yes | No | Yes | Yes | ||||||||||||||
|
Here’s a use case nearly all browsers agree on. |
|||||||||||||||||||
|
Zoom
Pinch- or double-tap zoom
|
Yes | No | Up to 2.3 | Yes | No | No | |||||||||||||
|
|||||||||||||||||||
|
Browser bar
Scroll the browser toolbar into and out of view
|
Yes | No | Up to 2.3 | Yes | No | Untest |
No | ||||||||||||
|
|||||||||||||||||||
|
Keyboard
The software keyboard pops up
|
Yes | No | Yes | PB | Almost | Untest |
Yes | No | |||||||||||
|
|||||||||||||||||||
| Layout viewport | |||||||||||||||||||
|
Meta viewport
Changing the meta viewport value
|
Yes | Yes | Yes | Untest |
Yes | Untest |
Yes | Untest |
|||||||||||
|
|||||||||||||||||||
| HTML element | |||||||||||||||||||
|
Grow vertically
Content is added to the page so that it grows
|
Not sure | Yes | No | Yes | No | Yes | No | ||||||||||||
|
|||||||||||||||||||
|
Grow horizontally
An element is made very wide so that the page grows horizontally
|
Yes | Yes | No | Yes | No | Yes | Yes | ||||||||||||
|
|||||||||||||||||||
|
Drag and drop
Drag an element just beyond the window border
|
Yes | Yes | No | Yes | Untest |
Yes | Yes | ||||||||||||
|
|||||||||||||||||||
| Other | |||||||||||||||||||
|
Zoom settings
Changing the default text size in the settings
|
Yes | Untest |
No | Untest |
Yes | Untest |
No | ||||||||||||
|
|||||||||||||||||||
| Property | Opera Mobile | Safari | Android | Black |
Dolfin | Symbian | Palm | MeeGo | Firefox | ||||||||||
| Presto | WebKit | Gecko | |||||||||||||||||
I also tried to test whether some browsers fire the resize event before the load event. The browser probably starts with a generic width for an as-yet unknown new page, and may adjust the width of the layout viewport or the HTML element as meta viewports or very wide elements come in. They may do so, but according to my test page they don’t fire resize events.