I am currently developing a client side application which will be designed for both, smartphones and tablets. Therefore it will get two different layout modes.
I would go with detecting the screen resolution, as it should not really matter if the browser is a phone or tablet, the only thing that should affect is the layout. And the best thing to determine which sized layout to use, would be the resolution.