Click here to Skip to main content
13,006,281 members (72,839 online)
Click here to Skip to main content


333 bookmarked
Posted 28 Mar 2006

Extended .NET 2.0 WebBrowser Control

, 29 Mar 2006
Extending the .NET 2.0 WebBrowser control.
<SCRIPT language="Jscript">
  // This function will create an error, because "someObject" does not exits
  function MakeError()
  // The first pop-up will succeed, the second will not
  function Popup()
    var winRef ="about:blank");
    // Check whether the window was blocked
    if (winRef != null)
      winRef.document.write("Hello world! - This is a pop-up blocker test.");
      alert('The pop-up Was Blocked');
  function fn_Load()
    // First try the pop-up blocker
    // Next try something that causes an error
  BODY {font-family: verdana; font-size: 12;}
  H1 {color: red; font-size: 16;}
  H2 {color: blue; font-size: 14;}
<Body onload="fn_Load();">
  <H1>These are a few simple tests to test the functionality of the browser</h1>
  <p>If you allready see a pop-up, this can be because of the fact that you
  have the pop-up blocker disabled, or are running on Windows 2000 or lower.</p>
  <h2>Script error testing</h2>
    <li>When you load this document, you should also encounter a script error. This is on purpose.</li>
    <li>Hit F5 to see if the script errors are still caught after a refresh</li>
    <li>Click "Create an error" to test script error functionality</li>
  <!-- The error button -->
  <Input type=button onclick="MakeError()" value="Create an error">
  <h2>Closing windows</h2>
  <!-- Try to close the window -->
  <p>With this button you can try to close the current window.</p>
  <Input type=button onclick="window.close()" value="Close window">
  <h2>Pop-up blocker</h2>
  <!-- Try to create a pop-up without the user's concent -->
    <li>A pop-up can be displayed when the document is loaded. If not, an alert window will notify you. This is the kind of pop-ups you want to avoid.</li>
    <li>A pop-up window can be because of an user action. This can be done using the button below.</li>
    <li>When you click on the button, and you get the message that the pop-up is blocked, see if you have the filter level set to high. When this is the case, use the Ctrl Key to override the pop-up blocker</li>
  <Input type=button onclick="Popup()" value="Try a pop-up" />

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Jeroen Landheer
Web Developer
Chile Chile
I am
- born in The Netherlands
- living in Chile together with my wife.
- a Microsoft Certified Professional Developer on all 3 areas (Windows, Web and Enterprise)
- an MCITP on Microsoft SQL Server 2005 (Database Administrator)
- an active programmer for about 14 years.
- a business owner, of a Dutch company called "The Wheel Automatisering" (
- a coder in C#, VB.Net and Managed C++.
- someone who likes to share knowledge

For fun I like to go out with my dogs, enjoy the sun or write some articles that I share with the community.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170628.1 | Last Updated 29 Mar 2006
Article Copyright 2006 by Jeroen Landheer
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid