Results 1 to 25 of 25

Thread: [RESOLVED ]Setting webbrowser contents

  1. #1

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611

    [RESOLVED ]Setting webbrowser contents

    Is there a command that is to opposite of

    Code:
    Text1 = brwBrowser.Document.documentElement.InnerHTML
    which I can use to put an ascii string into a webbrowser without having to load it from the disc (i.e. without having to navigate)?
    Last edited by Kzin; Nov 29th, 2001 at 10:29 AM.
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  2. #2
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226

    Question try this

    brwBrowser.Document.documentElement.InnerHTML = Text1 ???
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  3. #3

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Nope not that one
    Attached Images Attached Images  
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  4. #4
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    All I can suggest then is to write it to a temp file and then use Navigate
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  5. #5

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Originally posted by mlewis
    All I can suggest then is to write it to a temp file and then use Navigate
    That's what I've done before but I don't want to write to disk with this particular app
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  6. #6
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Guess you're stuck then...
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  7. #7
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    How about something like this. (Don't forget to remove the space between "about" and ":")
    VB Code:
    1. Private Sub myPage()
    2.     Dim strHTML as String
    3.    
    4.     strHTML = "about:<html>"
    5.     strHTML = strHTML & "<head><title>My Page</title></head>"
    6.     strHTML = strHTML & "<body bgcolor=#000000 text=#FFFFFF>"
    7.     strHTML = strHTML & "<center>Hi There!</center>"</body>"
    8.     strHTML = strHTML & "</html>"
    9.  
    10.     WebBrowser1.Navigate strHTML
    11. End Sub

  8. #8

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Originally posted by Bloodeye
    How about something like this. (Don't forget to remove the space between "about" and ":")
    VB Code:
    1. Private Sub myPage()
    2.     Dim strHTML as String
    3.    
    4.     strHTML = "about:<html>"
    5.     strHTML = strHTML & "<head><title>My Page</title></head>"
    6.     strHTML = strHTML & "<body bgcolor=#000000 text=#FFFFFF>"
    7.     strHTML = strHTML & "<center>Hi There!</center>"</body>"
    8.     strHTML = strHTML & "</html>"
    9.  
    10.     WebBrowser1.Navigate strHTML
    11. End Sub
    Its looking very promising even if it did not work for me when I tried it. Have you tested it bloodeye?
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  9. #9
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Try webbrowser.navigate "about:test" and see what pops up.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  10. #10
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    there is also a way to write to the webbrowser...
    but I cant remember!!!

    something like

    Webbrowser1.Document.Write (thats not it...but...)

    well I forgot about that one Bloodeye..

    That way works much better than the Write method.

    Kzin..hes got an extra " in there....and be sure to remove the space between about and :
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  11. #11

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Yes that works - now I'll try some html
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  12. #12

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    so
    Code:
    <html><body>???</body></html>
    is a valid displayable .htm file but will not show if you use about:

    We must be nearly there - are their any other commands like about?
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  13. #13

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Originally posted by geoff_xrx
    Kzin..hes got an extra " in there....and be sure to remove the space between about and :
    Thanks I got that one but it wasn't the problem
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  14. #14

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Originally posted by geoff_xrx
    there is also a way to write to the webbrowser...
    but I cant remember!!!

    something like

    Webbrowser1.Document.Write (thats not it...but...)

    Keep thinking -

    I've been looking on http://msdn.microsoft.com/library/de...er/wbentry.asp but can't see the answer but we must be nearly there!
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  15. #15
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    Here's another way. Give this a try. Remove the space after "about"
    You will need to make a reference to the (Microsoft HTML Object library).

    VB Code:
    1. Dim htmlDoc As HTMLDocument
    2.  
    3. Private Sub Command1_Click()
    4.     htmlDoc.body.innerHTML = Text1.Text
    5.     WebBrowser1.Document.body.bgColor = "#000000"
    6.     WebBrowser1.Document.body.Text = "#FFFFFF"
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10.     Dim strHTML As String
    11.    
    12.     strHTML = "<html><head><title>My Page</title></head><center>Hi There!</center></body></html>"
    13.  
    14.     Text1.Text = strHTML
    15.     WebBrowser1.Navigate "about:blank"
    16. End Sub
    17.  
    18. Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
    19.     Set htmlDoc = Nothing
    20. End Sub
    21.  
    22. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    23.     Set htmlDoc = WebBrowser1.Document
    24. End Sub

  16. #16
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    That won't work, you have to set the Webbrowser's document property to the htmlDoc somewheres!
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  17. #17
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    Originally posted by mlewis
    That won't work, you have to set the Webbrowser's document property to the htmlDoc somewheres!
    Hmmmm.....Maybe you should try the code before you post.
    BTW: I have set htmlDoc = WebBrowser1.Document in the DocumentComplete event.

  18. #18

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Yes - it works - impressive!!
    Thanks
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  19. #19
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Originally posted by Bloodeye


    Hmmmm.....Maybe you should try the code before you post.
    BTW: I have set htmlDoc = WebBrowser1.Document in the DocumentComplete event.
    How does the WebBrowser know to reference the htmlDoc object?

    Set A = B does NOT set B to A!!!
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  20. #20
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    I really have no idea what it is that your asking....?
    The htmlDoc Object, I believe is the same as the "Document Object" within the WebBrowser Control.
    Maybe someone else can help explain this better.

  21. #21
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    NRGH.

    The htmlDoc object in your code is a VARIABLE!!!!!! FOR THE WEBBROWSER TO HAVE THE SAME HTML CODE AS THE VARIABLE YOU MUST WRITE

    Set WebBrowser.document = htmlDoc

    !!!!!!!
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  22. #22
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    n/m I figgered it
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  23. #23

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Another presumably simplier one

    Text1 = brwBrowser.Document.documentElement.InnerHTML

    gets the html - is there an easy way to get the text that is displayed in the webbrowser as a string without the tags/formatting
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  24. #24
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    For the Text without the formatting try either:

    Text1 = brwBrowser.Document.documentElement.InnerText
    OR
    Text1 = brwBrowser.Document.documentElement.OuterText

  25. #25

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Thanks - that worked well
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

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