open a web page in mobile version

Post Reply
ericktux
Posts: 11
Joined: Thu Oct 29, 2020 10:11 am

open a web page in mobile version

Post by ericktux »

Hello friends, how can I open a website in a mobile version? (as if it were a smartphone)

Thank you
User avatar
salvadordf
Posts: 3067
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: open a web page in mobile version

Post by salvadordf »

Hi,

As far as I know, the DevTools option to simulate other devices is not supported by CEF but you can try creating an OSR browser with the same dimensions and screen scale settings. You may also need to change the user agent string.

These DevTools methodds might be handy too :
https://chromedevtools.github.io/devtools-protocol/tot/Emulation/
User avatar
salvadordf
Posts: 3067
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: open a web page in mobile version

Post by salvadordf »

I did some more testing and the new "Chrome runtime" mode does support the device emulation! :D

Run the TinyBrowser2 demo to see that option when you inspect a web page.
ericktux
Posts: 11
Joined: Thu Oct 29, 2020 10:11 am

Re: open a web page in mobile version

Post by ericktux »

Hello friends, thanks for your answers at the moment this code is working for me, now the browser opens in mobile version :D

procedure CreateGlobalCEFApp;
begin
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.cache := 'cache';
GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized;
GlobalCEFApp.UserAgent := 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
end;
Post Reply