473,378 Members | 1,099 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,378 software developers and data experts.

Clearing WebBrowser contents

Hi Folks,

Wonder if you can help...

All I'm trying to do is load a couple of simple HTML pages (in memory)
into the WebBrowser control, one after the other. I don't seem to be
able to clear the contents of the WebBrowser before I show the next
page, they're appended one after the other.

I've got some really simple code:

private void Form1_Load(object sender, System.EventArgs e)
{
Object o = null;
axWebBrowser1.Navigate("about:blank", ref o, ref o, ref o, ref o);
document = (IHTMLDocument2) axWebBrowser1.Document;
document.writeln("<h1>One</h2>");
}

private void button2_Click(object sender, System.EventArgs e)
{
document = (IHTMLDocument2) axWebBrowser1.Document;
document.clear();
axWebBrowser1.Refresh();
document.writeln("<h1>Two</h1>");
}

Any suggestions, I'm being stupid, but I can't see why and I've spent
too long on this already.

Thanks Dudes.

John
Nov 15 '05 #1
2 13877
Hi JH,

This is a guess.

Try navigating to about:blank again in button2_Click..

Regards,
Fergus
Nov 15 '05 #2
"Fergus Cooney" <fi******@tesco.net> wrote in message news:<OV**************@TK2MSFTNGP11.phx.gbl>...
Hi JH,

This is a guess.

Try navigating to about:blank again in button2_Click..

Regards,
Fergus


Thanks Fergus, I tried that before. Just for reference the answer to
this one is "RTFM". :) The documentation states that this method isn't
implemented for IHTMLDocument2, and I should've used:

document.write("");
document.close();

Works fine.

Thanks again,
John
Nov 15 '05 #3

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

Similar topics

5
by: Charles Law | last post by:
Sorry for the cross post, but I'm not sure who is best placed to answer this one. This is the most bizarre behaviour of MSHTML and streams. I have a WebBrowser control that contains nothing...
5
by: William Payne | last post by:
How do you get rid the contents in a std::stringstream? I'm using one in a for loop to format some status messages which I print to the screen. The stringstream member function clear() only clears...
8
by: Prosperz | last post by:
Hi, I would like to make thumbnails of web page by capture content of a WebBrowser. By example, capture http://www.google.com. I used WebBrowser control with Framework 2.0. I try this : ...
4
by: markshowell | last post by:
I'm trying to use the following code to clear the contents of the two worksheets named Unpaid and Payments and then locate the cell pointer for that worksheet in cell A1 - ...
5
by: mabond | last post by:
Hi recently read a posting and reply about Excel processs still running after the Appliction.Quit was called. Thought I might be able to use the same...
0
by: Bob Bryan | last post by:
After adding a WebBrowser control to my form (VS 2005), and the following 2 lines of code to a click event: webBrowser1.Navigate(new Uri(NextURL)); String PageData = webBrowser1.DocumentText; ...
1
by: David Veeneman | last post by:
In .NET 2.0, how do I clear the contents of a web browser control? I'm using a WebBrowser control in a Windows Form app to display strings genrated by my application and formatted as HTML--I'm...
3
by: Zytan | last post by:
The Immediate Window is filled with debugging output from previous runs. Besides manually right clicking and clearing it, is there a programmatic way of doing this? Should I create and use a...
0
by: Johnny Jörgensen | last post by:
Does anybody have a good idea of how to save the WebBrowser control's contents in a PDF file? You could have a PDF printer and simply use WebBrowser1.Print, but I need to know the filename...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.