I'm trying to use a webview to load a webpage, my problem is the webview automatic shows the mobile version of the page, probably some user-agent string in the header makes this. I wonder if there is a way to force the web view to show desktop version of websites? For instance a way to alter the header?
It works fine when using a webrequest and manually setting the user-agent, but would love to be able to use the webview directly with desktop version. Any ideas on this?
web.SetUserAgent(navigator.userAgent.replace(/android/gi,"secret"));
You can test whether the user agent is being changed by running the test code below.
If the page displays a string including the word "Android" please let us know.
function OnStart()
{
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
web = app.CreateWebView( 0.9,0.9 )
web.SetUserAgent(navigator.userAgent.replace(/android/gi,"secret"));
lay.AddChild( web );
web.LoadUrl( "http://sgarman.net/ua.php" );
app.AddLayout( lay );
}
But when set UserAgent as you recommend, remove "android". It's not working.
I need webview loading site as desktop mode very much. So, please give me the full solution for that in DS soon.
Thank you very much.
If the particular website you are having trouble with does not respond to that change in useragent, you will need to find out how it decides which version to serve.
The way to find this may be by examining the html if you are lucky.
If not, you may need to ask the owner of the website or search for information from other users of the site.
Some website designers are very determined to control which view you see and it may be virtually impossible to override.
Try removing "Mobile" as well as "Android"
web.SetUserAgent(navigator.userAgent.replace(/android|mobile/gi,"secret"));
the only way is to change the viewport size
I think not only set userAgent but also set some other settings to show desktop site for sure. Ex: wide viewport or zoom.
How to set that settings in DS ?
web = app.CreateWebView( 1,1,"AllowZoom,AutoZoom,Wide,NoScrollBars" );
That should set most of the settings above.
?nomobile=true
?mobile=0
inurl:"nomobile