Important alert: (current site time 7/15/2013 9:15:45 AM EDT)
 

winzip icon

Web Browser / IE Clone

Email
Submitted on: 1/2/2007 8:07:37 AM
By: Thomas Maxwell  
Level: Intermediate
User Rating: By 30 Users
Compatibility: VB.NET
Views: 76974
author picture
(About the author)
 
     IE Clone – VB.Net I received a few email regarding my past quick example of a browser in VB.Net, This example application takes it to the next level and shows a lot of what can be done using the web browser control in VB.Net. It is a fairly good clone of IE, it shows the following and more: Opening Files | Saving | Print Preview | Page Setup | Print | Import / Export | Page properties | Send to desktop | Copy | Select All | Find | View Source | Privacy Report | Internet Options Dialog | Adding Favorites | Organizing Favorites | Navigation | Stopping Pop-Ups | Trapping New windows (new app not IE) | Auto complete combo box (some code from all over there, not all mine) | Secure Lock Icons | Progress bar in status bar w/o imbedding | Full Screen | Hide / Show Tool, Status Bars | Updating status bar | Opening folders | tree view | Context Menu (Right click on cookies tree view) | Deleting Files | Reading from a file (see favorites code) and more, poke around a bit. If you are needing to write a web browser application in .net, this should be all you need to get you started, if not all the way there. For those who asked about working with the IE DOM, this is not covered in the example and is a completely different subject in many ways, I may post some examples on working directly with the DOM in the future. I hope you find this useful and as always please vote if you do.

 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
// for :Web Browser / IE Clone
//**************************************
If you use all or part of this example in your application, please give credit in the about screen or in the comments of your code. Thanks.
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

1/9/2004 8:17:56 AM

I couldn't open the files as I am having vs 2002 Could u plz save it as vb 2002 project..
thx
(If this comment was disrespectful, please report it.)

 
1/10/2004 12:10:47 PM

Very nice but what about having it for people who have VS 2002
(If this comment was disrespectful, please report it.)

 
1/11/2004 3:58:51 AMThomas Maxwell

Try this link...
http://www.eggheadcafe.com/articles/20030425.asp or try http://www.codeproject.com/macro/vsconvert.asp
it has conversion article there. I no longer use VS. 2002.
Hope this helps
(If this comment was disrespectful, please report it.)

 
1/11/2004 4:43:03 AMCodeFester

I find that if I carefully recreate the modukes by copying the contents of each code window into a VS2002 codewindow then save it off as the same name that it usually works fine. It can be a tedius thing if there are alot of codefiles (and it won't help you on binary files (designtime embeded resources...). However, if you are truly looking to learn more about .NET by reading this gentleman's code, then it is worth it to go through the excersise of rebuilding the project...
(If this comment was disrespectful, please report it.)

 
1/11/2004 4:47:16 AMCodeFester

oh yeah, don't forget to establish any references in the new project (that may have been present in the 2003 project)... To view them w/o VS 2003 open the project file in notepad and locate the XML section named "References".

(If this comment was disrespectful, please report it.)

 
1/11/2004 7:17:00 AM

Good Stuff!
(If this comment was disrespectful, please report it.)

 
1/14/2004 1:46:44 AM

Hi, its very nice but not work at my PC and need the tool you use it.
how can i run it .
(If this comment was disrespectful, please report it.)

 
1/14/2004 2:01:38 AMThomas Maxwell

I used Visual Studio 2003 to write the code, it is written in VB.NET. If you are using an earlier version see the comments above in order to load and run the example. If you like it, please vote. Thanks
(If this comment was disrespectful, please report it.)

 
1/16/2004 1:51:12 AMRick Winscot

great submission - any idea how to diable the backspace key?
(If this comment was disrespectful, please report it.)

 
1/16/2004 2:04:17 PMThomas Maxwell

Do you mean denying the last page?
(If this comment was disrespectful, please report it.)

 
1/27/2004 4:47:12 PMRick Winscot

I get some interesting results when capturing the new window event and sending the url to another instance of the web browser... if you are willing to discuss - email me rickly@zyche DOT com.
(If this comment was disrespectful, please report it.)

 
2/7/2004 9:51:52 PM

seems the prgram is great ,but can't build get .i get 35 build errors,i am ofcourse using visual studio version 2003.the most line i get error is SHDocVw is not defined
what's the problem
help appreciated
(If this comment was disrespectful, please report it.)

 
2/8/2004 12:39:32 AMThomas Maxwell

Hi
Seems alot of people are having
that problem. Try right clicking on the
toolbox and selecting and select
add/remove items. In the selection
dialog, click the com tab and add the
Microsoft Web Browser Control. I named
the browser wb, so you should name this
control wb.
Hope this helps everyone.

(If this comment was disrespectful, please report it.)

 
2/8/2004 10:48:26 AM

i did exactly u told me,now i don;t get build errors and it ran successfylly,but when i run the program ,i get this message box: object reference not set to an instance
of an object. and when i click ok,the browser comes up,but i can;t go to any url i type in the top.the home,search,go ,any of the buttons doesn't work

what could be the problem.

thanks for u help
(If this comment was disrespectful, please report it.)

 
2/9/2004 4:19:11 AMFrank Macall

Great software
(If this comment was disrespectful, please report it.)

 
2/10/2004 5:18:21 PM0C0DE

FOR ALL OF YOU WHO USE 2002 (LIKE ME) VERY SIMPLE WAY:

open the project file (one that looks like a folder, then on bottom left has a smaller icon of a html page kinda) with notepad, then edit the following values to these:

ProductVersion = "7.0"
SchemaVersion = "1.0"

save that, and when you open the solution it will work.
(If this comment was disrespectful, please report it.)

 
2/11/2004 8:31:09 PM

I get an error saying that im miss these files:
Interop.SHDocVw
AxInterop.SHDocVw
(If this comment was disrespectful, please report it.)

 
2/14/2004 5:03:08 PMThomas Maxwell

Look above to add control to project, that should work
(If this comment was disrespectful, please report it.)

 
2/15/2004 1:32:51 PMfeniks

Very nice but when the window is closed by a script, the ie clone doesn't close and another navigation is impossible.
Any idea !!!
(If this comment was disrespectful, please report it.)

 
2/16/2004 7:41:33 PMThomas Maxwell

Hi,
I really only added the new window and the stop pop-ups features to show how to begin to implement these types of features. You should look at the code and try to trap different link types - ie:(javiscript:open), (target="new") - etc. It should not be to hard to trap and parse these to deal with them however you would like to.

Hope that helps.

(If this comment was disrespectful, please report it.)

 
4/14/2004 10:47:06 PMJim_Hubbard

This code just flat doesn't work. I followed your 2/08/2004 advice and when I try and name my instance of the webbrowser control "WB" it tells me there is already a component named "WB". If I rename my component "WBx" and run the code I get a "Object reference not set to an instance of an object" error but the app starts. But when I try and surf to a web page, I get yet another error.

Is there a working post of the code?
(If this comment was disrespectful, please report it.)

 
4/17/2004 3:12:44 AMJim_Hubbard

Got it!

You must first remark out the line
(If this comment was disrespectful, please report it.)

 
4/17/2004 3:14:06 AMJim_Hubbard

OK....we'll try that again....

You must first remark out the line...

Friend WithEvents WB As AxSHDocVw.AxWebBrowser

Then you can add the webbrowser control and rename it to WB.

After that everything works great!

Fantastic job!
(If this comment was disrespectful, please report it.)

 
4/17/2004 9:25:52 AMThomas Maxwell

I am glad you got it going and like it. Hopefully that will help others get it running as well.
(If this comment was disrespectful, please report it.)

 
5/10/2004 4:46:42 PMAsylum Studios

Is there a VB.NET to VB6 Convertor? Please Help me convert this code to VB 6. Thanks
(If this comment was disrespectful, please report it.)

 
7/6/2004 12:21:39 PMChris Myers

Asylum: If you are using VB6 then you should look someplace else. Like the Visual Basic category .Net is drasticaly different from 6
(If this comment was disrespectful, please report it.)

 
7/11/2004 3:49:57 PMCalcMan222

How in the world do you rename the control? any help? I am new to VS .NET

thanks
(If this comment was disrespectful, please report it.)

 
8/6/2004 12:28:42 PM

Excellent example, a couple of questions though, HOW would you call the FIND AGAIN OLE, and HOW do you automatically scroll an AXWEBBROWSER window to the bottom, or gain control over positioning?? My end objective would to be PROGRAMATICALLY select specific text in the HTML, as if the MOUSE LEFT CLICK DRAG was used.

THANKS
(If this comment was disrespectful, please report it.)

 
8/16/2004 11:12:17 AM

Hi,
I am trying to run this code in VB2002,
did
#--
ProductVersion =
(If this comment was disrespectful, please report it.)

 
8/16/2004 11:17:19 AM

#Re-writing coz of some posting error.
Hi,
I am trying to run this code in
VB2002,
did
2/10/2004 5:18:21 PM:0C0DE
2/8/2004 12:39:32 AM:Thomas Maxwell

but I am getting
=> System.Windows.Forms.FolderBrowserDialog not defined.
Error is some where here

Friend WithEvents fBrowse As System.Windows.Forms.FolderBrowserDialog

can any one help?
thanks
(If this comment was disrespectful, please report it.)

 
8/18/2004 2:34:36 AM

For time being,
I just comment out few of the objects and I manage to make it run.
I have no idea , coz I have no knowledge on VB.Net,
any way good job I am really happy to find this example!

Any one made a C# convert manualy ?
(If this comment was disrespectful, please report it.)

 
10/13/2004 2:11:33 AM

why i cannot download this code?
it tells "system cannot find the specified files"..
(is that file no longer exist??)
(If this comment was disrespectful, please report it.)

 
10/16/2004 2:47:21 AM

Great app, but i got a question. When the Pop-Up blocker is enabled, it blocks all new windows as well. Even from File-New-New Window, or right click -Open in new window. Is there a way around this? Apart from that, it's great :)
(If this comment was disrespectful, please report it.)

 
10/21/2004 6:44:22 PM

This is definitely the best browser example I have seen so far. I did find some functions in other examples that would make this one even better. For exampl, the code below will accurately enable and disable your back and forward buttons when appropriate and only when appropriate:

Private Enum csc
Back = 2
Forward = 1
Other = -1
End Enum

Private Sub AxWebBrowser1_CommandStateChange(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_CommandStateChangeEvent) Handles AxWebBrowser1.CommandStateChange
Select Case e.command
Case csc.Back
Me.tbBack.Enabled = e.enable
Case csc.Forward
Me.tbFwd.Enabled = e.enable
Case csc.Other
Me.tbStop.Enabled = Not e.enable
End Select
End Sub


Of course, my browser and buttons are named different than yours, but the idea is there.
(If this comment was disrespectful, please report it.)

 
10/21/2004 6:49:15 PM

If anyone could supply a good way to enable visual styles in the browser like IE6 does on XP, I would greatly appreciate it.
(If this comment was disrespectful, please report it.)

 
10/28/2004 12:38:00 PMB1ll gates

I would like to know how to export the view source to a string not to notepad. The interop stuff is over my head but thanks for the effort. If you reply please send a message to justengland@yahoo.com
Thanks


(If this comment was disrespectful, please report it.)

 
11/30/2004 5:00:22 PMWoleTall

Hi Thomas,

This question is not directly related to your code but perhaps yiu can help me. I wrote a VB.Net app that uses the COM Web Browser. It works fine on my development system (WinXP), but when I copy the program to another WinXP system, I get unhandled exceptions indicating that AxWebBrowser methods such as Navigate() cannot be found. I have verified that ShDocVw.dll is the same version as on my development system (6.0.2900.2518) so I'm stumped. Since you've spent a lot of time with the Web Browser Control, you may be able to help.
(If this comment was disrespectful, please report it.)

 
12/3/2004 4:24:50 PM

I Coudent Run That Project Dont Know WHY But It Gives 38 Erorrs
(If this comment was disrespectful, please report it.)

 
12/4/2004 6:48:25 PM

I ran your code and it
(If this comment was disrespectful, please report it.)

 
12/4/2004 6:53:36 PM

I ran your code and it worked great at first but then the favorites stopped working.
I checked to make sure that there was a URL in the tag but there wasn't!

What has gone wrong?
The tvFavorites displays all the favorites but you cannot click and navigate to them!

Help appreciated,

Vyasa
(If this comment was disrespectful, please report it.)

 
12/4/2004 6:55:01 PM

Browser worked great the first time.

The suddenly the favorites stopped working!

They load and show all the favorites, but there is no value in the tvNode's tag! So you cannot navigate using it...

Any way to fix this?

Thanks

Vyasa
(If this comment was disrespectful, please report it.)

 
12/13/2004 10:22:39 AM

Any ideas on how to display a javascript popup? (at present, it tries to open a new browser to an address of javascript:...., which obviously doesn't work)

Also, Thomas, could you please post your current email address? The talex one does not work anymore, right?

Thanks,

ABakshi
(If this comment was disrespectful, please report it.)

 
12/14/2004 4:29:46 AM

simply outstanding ... bravo
(If this comment was disrespectful, please report it.)

 
12/23/2004 11:01:54 AMThomas Maxwell

the email works, I have blocked alot of ip's from sending, if your emails are not getting through try a yahoo or hotmail email. Thanks for all the comments, happy holidays all!
(If this comment was disrespectful, please report it.)

 
12/30/2004 7:18:11 AM

I'd love to take a look at the code, but all I get is the dreaded
(If this comment was disrespectful, please report it.)

 
12/30/2004 7:19:09 AM

I'd love to take a look, but all I get is the dreaded "page cannot be displayed" from the download link. :(
(If this comment was disrespectful, please report it.)

 
1/1/2005 4:22:21 PMThomas Maxwell

To the favorites question above, the browser reads the favorites that is saved by Internet explorer as well as adds them using ie, so if your favorites do not work then the most likely cause is that they are not being added properly.
(If this comment was disrespectful, please report it.)

 
1/20/2005 11:01:48 AM

Your code does help me a ton in my work and study. Appreciate. :)
(If this comment was disrespectful, please report it.)

 
1/24/2005 4:23:05 PM

This is excellent code! It goes far beyond any other sample application I have been able to find - and boy have I been looking.

I'd love to see any articles or samples in the area of working with the DOM. I'm trying to build DOM function to automate information retrieval from a restricted website with a very complicated structure (which I am licensed to access) on my own, but as a fairly fresh newbie I'm finding it challenging.

Thanks! for making the browser code available - it made quite a few things clear to me. BTW, I understand shielding your email address, but you should reference a website that is aware of this code. This is the type of application for which I'd be happy to make an optional PayPal donation - now that I see how much it has helped me.

(If this comment was disrespectful, please report it.)

 
2/1/2005 1:48:41 PM

To answer ABakshi's question about javascript popups, here is some code you can place in your NewWindow2 event:

''''''Begin Code''''''''''
'Assuming you have a form for popups
Dim popupWindow As New frmPopup(Me)
e.ppDisp = & _
popupWindow.webBrowser.Application
popupWindow.Show()
popupWindow.BringToFront()''''''''End
Code''''''''''

This should open the popup into your form. It even works on the Gmail popups, which usually break other Web Browser clones.

Enjoy,
itzkakarot

(If this comment was disrespectful, please report it.)

 
3/4/2005 11:33:29 AM

Hi you guys,
I wonder if you can help me. I need to know how to monitor cookies request from web server and sending cookies header by our web browser. Then we print these events out.
Thanks for reading my message.
Dennis
(If this comment was disrespectful, please report it.)

 
3/22/2005 2:04:31 PM

Can anyone help me resolve this error?

A Runtime Error has occurred. Do you wish to Debug?
Line: 30
Error: 'windowHandle' is null or not an object

(Using the IE Clone) When a JavaScript popup window is clicked, the NewWindow2 event is fired as with any other popup window. The code I found above, which should handle this occurrence, appears to pass the event's functionality to the new form as intended, but unfailingly generates the error message above.

(I've added the code for this event in my second comment below.)

(If this comment was disrespectful, please report it.)

 
3/22/2005 2:06:03 PM

'Code at the beginning of the NewWindow2 event
Dim frmMe as Form1
'Where Form1 is the current form
'Code after some validation within the event
frmMe = New Form1
e.ppDisp = frmMe.WB.Application
'Where frmMe.WB is the WebBrowser Control
frmMe.Text = "New Window"
frmMe.WB.Navigate(tmpURL)
'Where tmpURL is the popup window target
frmMe.Show()
e.cancel = True
'End NewWindow2 event code
The code was compiled using Visual Studio.net 2003… The site where I've been having the problem is
http://gallery.gutterstar.net
…And originates when clicking on a thumbnail to view the full sized image.

Thank you for your help, and best wishes…
Bryan Garaventa

(If this comment was disrespectful, please report it.)

 
5/18/2005 4:36:33 PM

How can I prevent de popups?????

and..... when I open a link, this link got opened in the Internet Explorer, how can I repare this????

(If this comment was disrespectful, please report it.)

 
10/4/2005 1:46:43 PM

nice code man :)
but... i have some little problem here.
When i start the browser, the toolbar with the 'back' and 'forward' buttons is transperant. But when i click on the menu, the toolbar loads itself and makes all buttons appear. Any ideas of letting the toolbar work when the program starts?
(If this comment was disrespectful, please report it.)

 
10/17/2005 7:54:55 AMSifu

Nice code, but I still have a small problem:
I've re-registered the Axbrowser object, but get the build errors:
Form1.vb(1328): Overload resolution failed because no accessible 'ExecWB' accepts this number of arguments.
and
\Form1.vb(1340): Overload resolution failed because no accessible 'Navigate' accepts this number of arguments.

Commenting those lines solves the problem, however the browser object fails to resize with the main window.
I use vb.net 2003 with the windows Xp IE6.0 axbrowser components.
Any ideas would be helpfull!
Regards,
Eric

(If this comment was disrespectful, please report it.)

 
11/1/2005 5:45:18 AMPete

He're is a sample of reading the html.
Dim myDoc As New mshtml.HTMLDocumentClass
myDoc = CType(WB.Document, mshtml.HTMLDocumentClass)
Dim Page As String = myDoc.documentElement.innerHTML

based on this sample
http://www.codeproject.com/csharp/mshtml_automation.asp
(If this comment was disrespectful, please report it.)

 
11/1/2005 5:48:31 AMPete

Great code, but pages are much slower than IE to load.
Any ideas?
(If this comment was disrespectful, please report it.)

 
11/3/2005 7:42:29 PMhesam

Some Dll files not be found .
(If this comment was disrespectful, please report it.)

 
11/10/2005 12:49:05 AMLeon Aiossa

I can not download this but want to and don't know why. Planet source code wont let me. Please give me alternate download link or fix download. Thanks
(If this comment was disrespectful, please report it.)

 
2/13/2006 5:54:19 AMIndiresh

Hi Thomas,
That is an very intersting piece of code you have shared. But i do have a request on that. I want the code for the functionality of "Save As" under File Menu. If possible, could you please send that code across so that i can analyse and work on my project.

Thanks.
(If this comment was disrespectful, please report it.)

 
2/26/2006 5:10:08 AMTimDB

Hi,

There seems to be a problem with links that open in a new window.
With no adjustments to the code, a new window opens but shows the default home-page instead of the page behind the link.

if I comment out the code that checks if it's a new window, a new window opens, with the following url:

http://bezig%20met%20openen%20van%20pagina:%20**url To Open **

I have a dutch browser, the first part of the url means: busy opening page :
The second part (**url To open**) contains the actual page that must be opened.

For security reasons, I cannot announce the page I want to open, so I replaced the text with ** ... **

The new window that opens is a new instance of Form1, not an internet explorer instance.

Anny idea on how to fix this ?

Greetz,
Tim
(If this comment was disrespectful, please report it.)

 
2/26/2006 11:33:32 AMThomas Maxwell

Tim if you look through the code for popups and want new instances to open in IE, you will find some more area's that are trapping popups. If your intent is to not allow a user to know the url you will also have to override the right click menu in IE as well as the file -> properties menu item.

Hope that helps.
(If this comment was disrespectful, please report it.)

 
2/26/2006 11:40:46 AMThomas Maxwell

Indiresh,
Here is the save as code.

'Save As
Try
WB.ExecWB(SHDocVw.OLECMDID.OLECMDID_SAVEAS, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT)
Catch ex As Exception
MsgBox(ex.Message.ToString, MsgBoxStyle.Information, "PSC Example Browser")
End Try
(If this comment was disrespectful, please report it.)

 
11/2/2006 3:54:15 PMKiwil

Nice one....any plan to make it a tabe
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.