|
-
Nov 29th, 2001, 07:03 AM
#1
Thread Starter
Fanatic Member
[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 
-
Nov 29th, 2001, 08:42 AM
#2
Frenzied Member
try this
brwBrowser.Document.documentElement.InnerHTML = Text1 ???
-
Nov 29th, 2001, 08:45 AM
#3
Thread Starter
Fanatic Member
-
Nov 29th, 2001, 09:00 AM
#4
Frenzied Member
All I can suggest then is to write it to a temp file and then use Navigate
-
Nov 29th, 2001, 09:02 AM
#5
Thread Starter
Fanatic Member
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 
-
Nov 29th, 2001, 09:05 AM
#6
Frenzied Member
Guess you're stuck then...
-
Nov 29th, 2001, 09:24 AM
#7
Frenzied Member
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
-
Nov 29th, 2001, 09:29 AM
#8
Thread Starter
Fanatic Member
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
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 
-
Nov 29th, 2001, 09:35 AM
#9
Frenzied Member
Try webbrowser.navigate "about:test" and see what pops up.
-
Nov 29th, 2001, 09:40 AM
#10
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"
-
Nov 29th, 2001, 09:41 AM
#11
Thread Starter
Fanatic Member
Yes that works - now I'll try some html
 Looking for a friendly intelligent chat forum? Visit the white-hart.net 
-
Nov 29th, 2001, 09:46 AM
#12
Thread Starter
Fanatic Member
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 
-
Nov 29th, 2001, 09:47 AM
#13
Thread Starter
Fanatic Member
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 
-
Nov 29th, 2001, 09:49 AM
#14
Thread Starter
Fanatic Member
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 
-
Nov 29th, 2001, 10:02 AM
#15
Frenzied Member
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
-
Nov 29th, 2001, 10:05 AM
#16
Frenzied Member
That won't work, you have to set the Webbrowser's document property to the htmlDoc somewheres!
-
Nov 29th, 2001, 10:11 AM
#17
Frenzied Member
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.
-
Nov 29th, 2001, 10:28 AM
#18
Thread Starter
Fanatic Member
Yes - it works - impressive!!
Thanks
 Looking for a friendly intelligent chat forum? Visit the white-hart.net 
-
Nov 29th, 2001, 11:06 AM
#19
Frenzied Member
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!!!
-
Nov 29th, 2001, 11:27 AM
#20
Frenzied Member
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.
-
Nov 29th, 2001, 12:17 PM
#21
Frenzied Member
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
!!!!!!!
-
Nov 29th, 2001, 12:24 PM
#22
-
Nov 29th, 2001, 12:32 PM
#23
Thread Starter
Fanatic Member
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 
-
Nov 29th, 2001, 12:48 PM
#24
Frenzied Member
For the Text without the formatting try either:
Text1 = brwBrowser.Document.documentElement.InnerText
OR
Text1 = brwBrowser.Document.documentElement.OuterText
-
Nov 29th, 2001, 12:57 PM
#25
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|