简体   繁体   中英

How to resize Webbrowser content to fit 480 x 800

Im using some basic code to display a mobile website in my application using a web browser.

For some reason, if I use the standard browser it is sized correcly to 480 x 800 , but when I use the web browser in my application the page is way off more like 960 x 800.

Is there a way to force the size the page is displayed in the web browser?

The funny thing is that it was working a few months ago, but has suddenly gone haywire.

code is :

    string site1 = "http://m.domain.com";
   webBrowser1.Navigate(new Uri(site1, UriKind.Absolute));
   webBrowser1.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(webBrowser1_Navigated);

I was thinking I could force user agent by using the below code, but I am getting errors " no overload for method, 'Navigate' takes 4 arguments.

webBrowser1.Navigate("http://localhost/run.php", null, null, "User-Agent: Windows Phone 7");

Page using app:

在此处输入图片说明

Page using standard IE9 browser outside of application, but on handset.

在应用程序外部使用ie9

One place to start would be to sniff the request/response. There's clearly different HTML coming back from the server for the two requests. For the in-app browser, it clearly says it's having trouble identifying the device. If you can figure out what is different between the two requests, you might be able to force the in-app browser to make the request more like the out-of-app browser.

If you're using the simulator, Fiddler is a fantastic tool for that sort of thing. The first place I'd look is at the User-Agent header, which most sites use to figure out what type of browser is requesting the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM