如何自动放大WebBrowser控件下载的内容或缩放

时间:2012-08-03 02:37:37

标签: windows-phone-7

此代码将显示网页,并且在webbrowser控件中看起来很小。双击它,它将扩大网页。那么,当网页只包含一个图像时,如何在没有双击的情况下自动放大或缩放网页?感谢


webBrowser1.Navigate(new Uri(strWebPageUrl);

-----更新

它仍无法正常工作

 if (e.Error == null)
 {

  string strHtml = (string)e.Result; // if not using this, the result is the same.

string html = strHtml.Replace(-- Using your code exactly here -- )

webBrowser1.IsScriptEnabled = true;

 webBrowser1.NavigateToString(html);

}

1 个答案:

答案 0 :(得分:0)

您可以使用WebClient首先将HTML下载为字符串。

获得HTML后,您可以对其进行操作并更改初始比例

string html = e.Result.Replace("</head>", "<meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; maximum-scale=2.0;user-scalable=no;\"/><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" /></head>").Replace("</body>", "<script> document.body.style.zoom = 1.8; window.scrollTo(680,1000) </script></body>");

然后导航到字符串:

webBrowser1.NavigateToString(html);

感谢StackOverflow的earlier answer