Results 1 to 5 of 5

Thread: Displaying HTML in webbrowser control

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Displaying HTML in webbrowser control

    If I added some HTML to say, Text1.Text and then create a command button that would add the html from Text1 TO Webbrowser and display it, how would I do that?

    I've tried everything:

    WebBrowser1 = Text1.Text

    WebBrowser1.Document.Body.innerHTML = Text1.Text


    Any idea?

    Thanks a lot!
    Paul

  2. #2
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    Chesterfield, Mi
    Posts
    259

    Re: Displaying HTML in webbrowser control

    I'm fairly sure you have to save it to a temp file, and then navigate to the temp file.

    Could be wrong.

  3. #3
    Member
    Join Date
    Jun 2006
    Posts
    35

    Re: Displaying HTML in webbrowser control

    yea u have to save the file as .html like you would with notepad or web editor then use the address of the file C://file.html or wot ever.

    to my small knowledge u carnt do wot ur asking.

    I finaly gave something back to this site

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Displaying HTML in webbrowser control

    no you do not have to do that...

    Im working on a large tutorial on my website... click HERE to check it out

    but here is how you would do that...

    VB Code:
    1. Private Sub Form_Load()
    2.     WebBrowser1.Navigate "about:blank"
    3. End Sub
    4.  
    5. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    6.     If (pDisp Is WebBrowser1.Application) Then
    7.         If URL = "about:blank" Then
    8.             WebBrowser1.Document.write "<HTML>HTML GOES HERE</HTML>"
    9.         End If
    10.     End If
    11. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5
    Lively Member
    Join Date
    Jun 2005
    Posts
    94

    Re: Displaying HTML in webbrowser control

    Try this ...

    Private Sub Form_Load()
    Dim sHTML as String
    sHTML = <your html code>
    WebBrowser.Navigate "about:" & sHTML
    End Sub

    I'm not sure if it works all the time; but yeh, it worked this time!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width