resize a webpage opened from a webbrowser?

izzyq8

Member
Joined
Dec 29, 2007
Messages
21
Programming Experience
Beginner
is there any way to resize a webpage opened from a webbrowser to fit it into a certain location?
so basically i see the entire site even if its on a small web browser
 
There should have been, HtmlDocument.ExecCommand Method has a "SizeToControl", but documentation says "Not currently supported."

Another way is to append the Zoom CSS style to the document after it is loaded, I've only tested this with a few pages and it worked partly.
VB.NET:
Dim doc As Size = Me.WebBrowser1.Document.Body.ScrollRectangle.Size
doc = Size.Add(doc, New Size(50, 50))
Dim wb As Size = Me.WebBrowser1.Size
Dim factor As String = (Math.Round(Math.Min(wb.Width / doc.Width, wb.Height / doc.Width), 2) * 100).ToString & "%"
Me.WebBrowser1.Document.Body.Style &= ";zoom:" & factor
 
ok i tried it in the form load but gave me this error
"Object reference not set to an instance of an object."
 
You can't do it in form load because webbrowser haven't loaded a document yet, earliest is in DocumentCompleted event of browser. You should try it with a Button first. This is experimental.
 
that is assuming i have only one web browser
what if i got them like this
VB.NET:
Dim myTabPage As New TabPage()
        myTabPage.Text = "Moon" & (TabControl1.TabPages.Count + 1)
        TabControl1.TabPages.Add(myTabPage)
        Dim wb As New WebBrowser
        myTabPage.Controls.Add(wb)
i ahve created a way when i push a button they all go to a diffrent form and are separted from their tabs each to a seprate tabcontrol
i need that webbrowser(inside a tabcontrol) to be small
 
You have to learn AddHandler statement to add events dynamically.
There is also this approach available, but it has the disadvantange it will stall your app until page is loaded:
VB.NET:
' navigate
Do Until browser.ReadyState = WebBrowserReadyState.Complete
    Application.DoEvents()
Loop
' handle document here
 
Back
Top