Page 1 of 1

open a web page in mobile version

Posted: Mon Aug 09, 2021 11:32 pm
by ericktux
Hello friends, how can I open a website in a mobile version? (as if it were a smartphone)

Thank you

Re: open a web page in mobile version

Posted: Tue Aug 10, 2021 8:20 am
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/

Re: open a web page in mobile version

Posted: Tue Aug 10, 2021 8:30 am
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.

Re: open a web page in mobile version

Posted: Tue Sep 14, 2021 2:38 am
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;