User agent and resolution

Which is the best way to see the user agent and the resolution of the client browser.

The goal is to adapt the look to the application based on the client capabilities.
So programatically switch between the mobile view and the desktop view.

To see the user agent, add the web unit to the uses list and write:


procedure TForm1.WebButton1Click(Sender: TObject);
begin
  caption := window.navigator.userAgent;
end;

To get the screen resolution:

procedure TForm1.WebButton1Click(Sender: TObject);
begin
  caption := string(window.screen['width'])+':'+string(window.screen['height']);
end;