Results 1 to 7 of 7

Thread: Feeding Web Browser Control From Variables Rather Than Addressable Files

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    35
    Is there any way that a web browser control can be fed the elements of a page directly from variables stored in memory, i.e., without reliance on addressable files? The features that appear to come the closest to this capability are the innerhtml and outerhtml properties, e.g., brwWebBrowser.document.body.innerhtml = MyString, which are read/write for the body object as well as some other objects. But innerhtml and outerhtml still require at least a shell document to be read from an addressable file, and provide no mechanism for graphics data to be fed from anything other than an addressable file.

    John Fritch

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    John
    you can write to a webbrowser control using "about:"

    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    Dim strTemp As String
    
    
    strTemp = "<html><BODY><H1>Is this what you wanted to do?</h1></body></html>"
    
    WebBrowser1.Navigate "about:" & strTemp
    
    End Sub
    You could also write the data to out to a temp file and then delete it when it is finished with.

    You can include images including animated gifs in a resource file compiled into your program and have that written to a temp file before loading it back into the webbrowser control

    Mark
    -------------------

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    35

    Great! But still no apparent alternative for graphics.

    Thanks, Mark.

    That sure beats the snot out of what I was doing with innerhtml.

    Regarding graphics, yes, I'm writing .gif files, etc., to disk just before loading a page that references them. I then delete such files after the DocumentComplete event fires. I was hoping there would be something as elegant for graphics as what you indicated for normal content.

    John Fritch

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    You might be able to load a res

    when a page won't load and you get
    The page cannot be displayed

    this comes from the dll:

    res://c:\winnt\system32\shdoclc.dll


    in the page is reference to a gif called:
    pagerror.gif

    Seaching the hard drive while the page was loaded revealed tht it wasn't actually written to the hard drive.

    Some time ago, I started looking into how to do this but I got distracted and ended up doing some work!
    Mark
    -------------------

  5. #5
    New Member
    Join Date
    Oct 2000
    Posts
    6
    Originally posted by Mark Sreeves
    John
    you can write to a webbrowser control using "about:"

    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    Dim strTemp As String
    
    
    strTemp = "<html><BODY><H1>Is this what you wanted to do?</h1></body></html>"
    
    WebBrowser1.Navigate "about:" & strTemp
    
    End Sub


    This code won't work if strTemp contains (")
    It will show that the page is not available...
    How do I solve this?


  6. #6
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    here's 3 ways which work:

    Code:
    Option Explicit
    Const QUOTE = """"
    Private Sub Command1_Click()
    Dim strTemp As String
    
    'use a constant...
    strTemp = "<html><BODY>" & QUOTE & "Is this what you wanted to do?" & QUOTE & "asked Mark.</body></html>"
    
    'use chr() and the ascii code....
    strTemp = "<html><BODY>" & Chr(34) & "Is this what you wanted to do?" & Chr(34) & "asked Mark.</body></html>"
    
    'use html.... 
    strTemp = "<html><BODY>&#34; Is this what you wanted to do?&#34; asked Mark.</body></html>"
    
    WebBrowser1.Navigate "about:" & strTemp
    
    End Sub
    Mark
    -------------------

  7. #7
    New Member
    Join Date
    Oct 2000
    Posts
    6
    that means you'll have to:

    replace(variable, """, "& chr(34) &")

    dunno which one is faster compared to saving it to a file and webbrowser1.refresh.....

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