Is there a command that is to opposite of
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)?Code:Text1 = brwBrowser.Document.documentElement.InnerHTML
Printable View
Is there a command that is to opposite of
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)?Code:Text1 = brwBrowser.Document.documentElement.InnerHTML
brwBrowser.Document.documentElement.InnerHTML = Text1 ???
Nope not that onehttp://www.vbforums.com/attachment.php?s=&postid=673592
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 appQuote:
Originally posted by mlewis
All I can suggest then is to write it to a temp file and then use Navigate :(
Guess you're stuck then...
How about something like this. (Don't forget to remove the space between "about" and ":")
VB Code:
Private Sub myPage() Dim strHTML as String strHTML = "about:<html>" strHTML = strHTML & "<head><title>My Page</title></head>" strHTML = strHTML & "<body bgcolor=#000000 text=#FFFFFF>" strHTML = strHTML & "<center>Hi There!</center>"</body>" strHTML = strHTML & "</html>" WebBrowser1.Navigate strHTML End Sub
Its looking very promising even if it did not work for me when I tried it. Have you tested it bloodeye?Quote:
Originally posted by Bloodeye
How about something like this. (Don't forget to remove the space between "about" and ":")
VB Code:
Private Sub myPage() Dim strHTML as String strHTML = "about:<html>" strHTML = strHTML & "<head><title>My Page</title></head>" strHTML = strHTML & "<body bgcolor=#000000 text=#FFFFFF>" strHTML = strHTML & "<center>Hi There!</center>"</body>" strHTML = strHTML & "</html>" WebBrowser1.Navigate strHTML End Sub
Try webbrowser.navigate "about:test" and see what pops up.
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 :
Yes that works - now I'll try some html
sois a valid displayable .htm file but will not show if you use about:Code:<html><body>???</body></html>
We must be nearly there - are their any other commands like about?
Thanks I got that one but it wasn't the problemQuote:
Originally posted by geoff_xrx
Kzin..hes got an extra " in there....and be sure to remove the space between about and :
Keep thinking - :)Quote:
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...)
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!
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:
Dim htmlDoc As HTMLDocument Private Sub Command1_Click() htmlDoc.body.innerHTML = Text1.Text WebBrowser1.Document.body.bgColor = "#000000" WebBrowser1.Document.body.Text = "#FFFFFF" End Sub Private Sub Form_Load() Dim strHTML As String strHTML = "<html><head><title>My Page</title></head><center>Hi There!</center></body></html>" Text1.Text = strHTML WebBrowser1.Navigate "about:blank" End Sub 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) Set htmlDoc = Nothing End Sub Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Set htmlDoc = WebBrowser1.Document End Sub
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. :DQuote:
Originally posted by mlewis
That won't work, you have to set the Webbrowser's document property to the htmlDoc somewheres!
BTW: I have set htmlDoc = WebBrowser1.Document in the DocumentComplete event.
Yes - it works - impressive!!
Thanks
How does the WebBrowser know to reference the htmlDoc object?Quote:
Originally posted by Bloodeye
Hmmmm.....Maybe you should try the code before you post. :D
BTW: I have set htmlDoc = WebBrowser1.Document in the DocumentComplete event.
Set A = B does NOT set B to A!!!
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. :)
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
!!!!!!!
n/m I figgered it :rolleyes: :D
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
For the Text without the formatting try either:
Text1 = brwBrowser.Document.documentElement.InnerText
OR
Text1 = brwBrowser.Document.documentElement.OuterText
Thanks - that worked well