Bring back mobile version of website in WebBrowser control for wp7?

限于喜欢 提交于 2020-01-14 06:20:32

问题


Is it possible to bring back web pages in a mobile format, if available, before showing the normal rendering of a web page? I noticed I was getting both when I used it. Or is this enabled by default?

EDIT: For example in ie on the phone you can request to recieve webpages in a mobile version or desktop version. Is this option available to developers and if not what is the default for the control?


回答1:


Sadly, there's no API for toggling this setting - and no easy way to intercept the outgoing HTTP calls from the browser control.

Looking at some output from the emulator it looks like the mobile/full setting toggles this in the User-Agent:

Mobile - Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+Phone+OS+7.0;+Trident/3.1;+IEMobile/7.0;+Microsoft;+XDeviceEmulator)

Desktop - Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.1;+XBLWP7;+ZuneWP7)

Here also are some mobile agents captured "in the wild" - http://www.elucidsoft.com/blog/2010/11/19/windows-phone-7-user-agents/

It looks like this settings is a global setting for the OS - so whatever the user chooses in the browser settings is also used in your app (I think this is what I just saw).




回答2:


I had this problem for a very, very long time and I finally figured it out with the following:

string header = "User-Agent:Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7";

MyWebBrowser.Navigate(new Uri("http://www.google.com"), null, header);

The following header DID NOT work for me (on the gmail website):

Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+Phone+OS+7.0;+Trident/3.1;+IEMobile/7.0;+Microsoft;+XDeviceEmulator)




回答3:


The WebBrowser control does not expose an API that enables you to choose between the Desktop or the Mobile version of a web page. You could use Fiddler to trap the traffic for outgoing requests (from the emulator or a device) to see if there's anything in particular about the request that you might be able to replicate in yoru own requests.



来源:https://stackoverflow.com/questions/5329017/bring-back-mobile-version-of-website-in-webbrowser-control-for-wp7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!