S
sam
Hi
Just encountered a strange problem and wonder if it is a
bug ? I have the following piece of code....
try
{
IHTMLDocument2 MyDoc = (IHTMLDocument2
MyWebBrowser.Document;
IHTMLWindow2 MyWin = (IHTMLWindow2 ) MyDoc.open
("","_TEST_","","");
MyWin.document.writeln("line #1");
MyWin.document.writeln("line #2");
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
This opens the new WebBrowser, and writes the "line #1"
into it. But while writing the second line it throws an
exception "access denied"
Seems like I am allowed to access the "document" property
of the "IHTMLWindow2" only once.
If I try to access it again, I get this exception.
I found a work around.....
Basically I extract the MyWin.document into a variable of
IHTMLDocument2 and then invoke the writeln().
try
{
IHTMLDocument2 MyDoc = (IHTMLDocument2)
IWeb2.Document;
IHTMLWindow2 MyWin = (IHTMLWindow2 ) MyDoc.open
("","_TEST_","","");
IHTMLDocument2 MyDoc2 = (IHTMLDocument2)
MyWin.document;
MyDoc2.writeln("line #1");
MyDoc2.writeln("line #2");
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
This works, but it is not foolproof. if I try to access
MyWin.document again at some other time... eg when I
invoke the function again, I still get the exception.
Anybody any clues?
TIA
sam
Just encountered a strange problem and wonder if it is a
bug ? I have the following piece of code....
try
{
IHTMLDocument2 MyDoc = (IHTMLDocument2
MyWebBrowser.Document;
IHTMLWindow2 MyWin = (IHTMLWindow2 ) MyDoc.open
("","_TEST_","","");
MyWin.document.writeln("line #1");
MyWin.document.writeln("line #2");
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
This opens the new WebBrowser, and writes the "line #1"
into it. But while writing the second line it throws an
exception "access denied"
Seems like I am allowed to access the "document" property
of the "IHTMLWindow2" only once.
If I try to access it again, I get this exception.
I found a work around.....
Basically I extract the MyWin.document into a variable of
IHTMLDocument2 and then invoke the writeln().
try
{
IHTMLDocument2 MyDoc = (IHTMLDocument2)
IWeb2.Document;
IHTMLWindow2 MyWin = (IHTMLWindow2 ) MyDoc.open
("","_TEST_","","");
IHTMLDocument2 MyDoc2 = (IHTMLDocument2)
MyWin.document;
MyDoc2.writeln("line #1");
MyDoc2.writeln("line #2");
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
This works, but it is not foolproof. if I try to access
MyWin.document again at some other time... eg when I
invoke the function again, I still get the exception.
Anybody any clues?
TIA
sam