473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Modify a document before shown in WebBrowser

Is there any way to modify a document before it is displayed by a
System.Windows.Forms.WebBrowser control? The Navigating event occurs before
the document is loaded, but it does not expose the document object. On the
other hand, the DocumentCompleted event exposes the document object, but it
occurs after the WebBrowser has loaded the document. What I want is
something like a DocumentCompleting event (which does not exist) that would
allow me to customize specific documents for the user before the documents
are loaded by the WebBrowser.

Thanks,
Lance
Nov 23 '05 #1
7 3756
LjLeven,

This you need as first step 2005
DirectCast(WebBrowser1.Document.DomDocument,
mshtml.IHTMLDocument2).designMode = "On"

And than the rest from MSHTML, see the samples for that on MSDN.

If somebody has an alternative to set that designmode, than I will be glad
to see this.

I hope this helps,

Cor
Nov 23 '05 #2
Thanks for the idea. It seems like the type of thing that I am looking for.
Do you know which event I should handle in order to modify the document
before it is shown by the WebBrowser?

Thanks again,
Lance

Nov 23 '05 #3
Hi

We can do that in the DocumentCompleted event.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.WebBrowser1.Navigate("www.google.com")
End Sub

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal
e As System.Windows.Forms.WebBrowserDocumentCompletedEv entArgs) Handles
WebBrowser1.DocumentCompleted
Try
Dim doc As HtmlDocument = sender.Document
Dim he As HtmlElement = doc.GetElementById("2a")
MsgBox(he.InnerText)
he.InnerText += "Test"
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 23 '05 #4
Yes, that is the idea. The problem with that technique is that the document
can briefly appear in the unmodified state before the document's text is
modified and redisplayed. Is there any way to modifiy the document before it
is displayed by the WebBrowser?

Thanks again,
Lance

Nov 23 '05 #5
Hi

Based on my research, the DocumentComplete Event Fires when a document has
been completely loaded and initialized.
It is the only time it has been downloaded complete but not displayed by IE.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 23 '05 #6
Sounds good. Thanks a lot for your help!

Lance

Nov 23 '05 #7
Hi

You are welcomed!
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mark | last post by:
I am at my wits' end. I have the following code: WebBrowser1.Navigate ("c:\path\page.htm") Text1.Text = WebBrowser1.Document.Links.length Where the page.htm has the following HTML: <html>
1
by: mrbog | last post by:
Using the WebBrowser control, can someone load one of my web pages and see the HTML that has been generated by document.write() javascript? For example, if I have a page that has obfuscated...
1
by: JerryShea | last post by:
Hi, I am opening a word document (RTF) in a webbrowser control and automating it. Most automation features seem to work but when I execute: wordApp.ActiveDocument.PrintPreview() I get an...
6
by: Dave Slinn | last post by:
I have a VB app hosting the Webbrowser control. I would like to add "something" to the requests that app is submitted to our web application to indicate that its from this webbrowser and not a...
2
by: Dean Richardson | last post by:
Hello, I am currently building a windows application in VB.NET. At the moment I have a word document saved locally which I open with the WebBrowser control. I cannot seem to save the changes...
0
by: Dean Richardson | last post by:
Hello, I am currently building a windows application in VB.NET. At the moment I have a word document saved locally which I open with the WebBrowser control. I cannot seem to save the...
1
by: David Veeneman | last post by:
I'm writing an application that will manage a database of documents typed into the application by the user. Some documents will contain links to other documents. If the user clicks on a link, the...
6
by: Zytan | last post by:
Make a WebBrowser control, and make a bunch of timers / threads that continually call WebBrowser.Document.Write. Eventually, this happens: DisconnectedContext was detected Message: Context...
1
by: zdp | last post by:
Hi, all, My project is based on wxPython, and I need an IE control (i.e. WebBrowser ActiveX control). Although the wxPython implements a wrapped version (wx.lib.iewin.IEHtmlWindow), but it...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.