Click here to Skip to main content
13,050,614 members (85,773 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 14 Jun 2014

Capturing Entire Content of an Internet Explorer Window

, 14 Jun 2014
Rate this:
Please Sign up or sign in to vote.
A simple solution to capture entire HTML code of a web page which is displaying on Internet Explorer


Normally when you need to capture the contents of a webpage, it's enough to use .NET WebBrowser and it always works fine but recently I experienced a different situation: webpage data was displaying by using Ajax and JavaScript and because of that, the WebBrowser component could not catch everything and just displayed pre-designed parts of the web page.

As Internet Explorer was able to show everything perfectly, I decided to find a solution in order to catch the real-time content when page is displaying in Internet Explorer. After searching the web and being faced with a small programming error, finally I succeeded in optimizing an available code for this purpose.

That works fine for me so maybe it can be useful for someone else too.

Using the Code

Just open an Internet Explorer window, go to the website you want to capture and then use the following code. To make it easy to understand, I assumed my goal is to assign a textbox with HTML code of a special webpage.
Required references: MSHTML , SHdocVw

using System.Runtime.InteropServices;
using mshtml;
using System.Reflection;

SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
string filename;
 foreach (SHDocVw.InternetExplorer ie in shellWindows)
   {filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
    if (filename.Equals("iexplore") && ie.Name.Equals("Internet Explorer") &&
                    {   dynamic d = ie;
                        object v = d.Document.ActiveElement.InnerHTML;
                        textBox1.Text = v.ToString();


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Kaveh Yazdi Nezhad
Software Developer
Canada Canada
I'm a computer programmer Have worked within the information technology companies for over 10 years.

Object oriented programming, N-Tire architecture, SQL and Oracle stored procedures, HR, Accounting, Banking, Smart card programming, optimizing SQL queries and database structure and also training end-users are some of my experiences .

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 14 Jun 2014
Article Copyright 2014 by Kaveh Yazdi Nezhad
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid