2012-08-03 51 views
0

此代碼將顯示網頁,它在瀏覽器控件中看起來很小。做一個雙擊它,它會放大網頁。那麼,如何讓網頁自動放大或縮小,而不用雙擊它時,它只包含一個圖像?由於如何自動放大由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); 

} 

回答

0

你也可以先下載HTML爲使用Web客戶端的字符串。在StackOverflow的

webBrowser1.NavigateToString(html); 

回答感謝earlier answer

後你有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>"); 

然後導航到字符串。

+0

謝謝。我使用HtmlAgilityPack來獲取特定的圖像元素。因此,首先使用您的代碼替換然後使用HAP即可。將報告測試結果。謝謝 – MilkBottle 2012-08-03 09:48:18

+0

剛剛測試過使用webclient來獲取html,然後使用上述方法更改e.Result。結果:與之前一樣。我需要點擊放大WebBrowser ctrl內的網頁。 – MilkBottle 2012-08-03 10:36:04