PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Set HTML in WebBrowser control [resolved]-VBForums
Results 1 to 8 of 8

Thread: Set HTML in WebBrowser control [resolved]

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,784

    Question Set HTML in WebBrowser control [resolved]

    Hi

    I want to set the html that is created dinamically in a WebBrowser control, and I DON'T want to save it in a file, then open it.

    I tried something like this, and of course, it did not work...
    VB Code:
    1. Dim HTML As String
    2. HTML = "<html><body>Testing...</body></html>"
    3. WebBrowser1.Document.documentElement.outerHTML = HTML
    Last edited by CVMichael; Apr 30th, 2004 at 05:28 PM.

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    WebBrowser1.Document.body.innerHTML = HTML

    does that work?

    also make sure that it has naviagted to somewhere, like about:blank first.

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    this is the sort of thing you want to be doing ...
    VB Code:
    1. Dim HTML As String
    2. HTML = "<html><body>Testing...</body></html>"
    3.  
    4. WebBrowser1.Navigate "about:blank" '/// initialize the browser window
    5. DoEvents
    6.  
    7. With WebBrowser1.Document
    8.     .Open
    9.     .write HTML '/// write the HTML to your browser window
    10.     .Close
    11. End With

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,784
    I tried the folowing, and still getting errors:
    VB Code:
    1. WebBrowser1.Navigate2 "about:blank"
    2.     WebBrowser1.Document.documentElement.innerHTML = HTMLData
    3. 'Error: 91, Object variable or With block variable not set

    VB Code:
    1. WebBrowser1.Navigate2 "about:blank"
    2.     DoEvents
    3.     WebBrowser1.Document.documentElement.innerHTML = HTMLData
    4. 'Error: 600, Could not set the innerHTML property. Invalid target element for this operation.

  5. #5
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    you must use the document.open / write / close method as i posted ( you need to write the document as the innerhtml property is readonly )
    eg:
    VB Code:
    1. WebBrowser1.Navigate "about :blank" '/// initialize the browser window
    2. DoEvents
    3.  
    4. With WebBrowser1.Document
    5.     .Open
    6.     .write HTML '/// write the HTML to your browser window
    7.     .Close
    8. End With
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,784
    I got a blank page when I tried your code.

    Originally posted by dynamic_sysop
    this is the sort of thing you want to be doing ...
    VB Code:
    1. Dim HTML As String
    2. HTML = "<html><body>Testing...</body></html>"
    3.  
    4. WebBrowser1.Navigate "about:blank" '/// initialize the browser window
    5. DoEvents
    6.  
    7. With WebBrowser1.Document
    8.     .Open
    9.     .write HTML '/// write the HTML to your browser window
    10.     .Close
    11. End With

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,784
    Nevermind, I got it to work... stupid me, I had another control that was covering the webbrowser control.... I put it there while I was trying different things to make it work...


    dynamic_sysop, your code worked !
    Thanks...

  8. #8
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    What are those Open and Close methods for? You don't need to open or close a document to modify the HTML... This works as well.
    VB Code:
    1. Dim HTML As String
    2. HTML = "<html><body>Testing...</body></html>"
    3.  
    4. WebBrowser1.Navigate "about :blank" '/// initialize the browser window
    5. DoEvents
    6.  
    7. With WebBrowser1.Document
    8.     .write HTML '/// write the HTML to your browser window
    9. End With
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width