简体   繁体   English

如何调整Webbrowser内容的大小以适合480 x 800

[英]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. 我使用一些基本代码来使用Web浏览器在我的应用程序中显示移动网站。

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. 出于某种原因,如果我使用标准浏览器,则其大小正确地调整为480 x 800,但是当我在应用程序中使用网络浏览器时,页面的距离就更接近960 x 800。

Is there a way to force the size the page is displayed in the web browser? 有没有一种方法可以强制页面在Web浏览器中显示的大小?

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. 我当时以为可以通过使用以下代码来强制用户代理,但是我遇到错误“方法没有重载,'Navigate'需要4个参数。

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浏览器进行页面。

在应用程序外部使用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. 服务器针对这两个请求返回的HTML明显不同。 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. 如果您使用的是模拟器, Fiddler就是用于此类事情的绝佳工具。 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. 我首先要看的是User-Agent标头,大多数站点都使用该标头来确定请求页面的浏览器类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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