KennyGuoHsl

I have a problem with ie7, the method Navigate of interface IWebBrowser2 can't work as before.

My application is a C++ one, there is a Browser control (BrowserObj1) which is created in the main thread, hosted in the main window. The browser control will direct to a html file ( index.htm ) using method Navigate of IWebBrowser2. There is a custom control (MyControl) embeded in a table of the index.htm. My control is a visible one which hosts another Browser control (BrowserObj2). Till here, all the codes work fine under both ie6 and ie7.

Then, invoke method Navigate of BrowserObj2 in main thread, to load another html file (page1.htm). Now, the method Navigate fails to navigate page1.htm under ie7, and the return value is "the requested resource is in use". But it works fine under ie6. I tried to invoke the get_Busy method of the BrowserObj2 before the method Navigate for test, under ie7, the return value is VARIANT_TRUE, why was the BrowserObj2 busy But I have done nothing with the BrowserObj2 after it was initialized in MyControl. However, under ie6.0, is VARIANT_FALSE, not busy!! why

Should it have something to do with threads It seems that the method Navigate will new a thread to navigate a URL, is that true thus the BrowserObj2 which hosted in MyControl of the index.htm should be created in the new thread but not the main thread. How can I get it figured out

Any help would be much appreciated. Thanks in advance.



Re: Internet Explorer Web Development A problem with IWebBrowser2:Navigate() under IE7

Philippe LACHAISE

Hi,

I've got similar IE7-related problem :

Using Webbrowser Control in C# application (.net 1.1).
Used to work flawlessly in IE6, breaks with IE7.

Error message is ludicroulsy uninformative : "uncorrect character line 1" (or similar, it's in French).

Registry fix cannot be considered seriously (clients would NOT be happy with that) !

Changing "about:blank" (now in internet zone) for a local file does NOT make a difference.

Well, seems that Webbrowser Control has been screwed up in IE7. No working solution in view, stuck :(

Hope someone's listening at MS...





Re: Internet Explorer Web Development A problem with IWebBrowser2:Navigate() under IE7

Kun Cong - MSFT

Kenny:

How do you get the interface of BrowserObj2 in your application What's the initial content of BrowserObj2 Is there any dialog pops up during this process

Philippe:

It would be very helpful if you could provide details of the issue.





Re: Internet Explorer Web Development A problem with IWebBrowser2:Navigate() under IE7

Philippe LACHAISE

OK, I'll try and be as accurate as possible.

First, what used to work with IE6

I use The webbrowser control through .NET Interop, the standard way with Visual-Studio 2003, by importing "shdocvw.dll" from the COM controls.

Apart from some lost keyboard events it used to works fine and with quite a few lines of javascript I could implement an elaborate behavior.

I used to crate the HTML document by loading "about:blank"

// ...
object dummy = 0;
object flags = (0x04|0x08); // navNoReadFromCache
this.Navigate("about:blank", ref flags, ref dummy, ref dummy, ref dummy);
// ...

When DWebBrowserEvents2_DocumentCompleteEvent gets called I provide actual content in a textbook way :

// 1) Clear
this.htmlDoc2.open( "text/html", "_self", null, null );
this.htmlDoc2.write( "" );
this.htmlDoc2.close();
// 2) Write content
this.htmlDoc2.open( "text/html", "_self", null, null );
this.htmlDoc2.write( html ); // My content
this.htmlDoc2.close();

This html happens to contain <script> tags referring to local .js files.

I know that, starting with IE7, "about:blank" belongs to "Intenet zone" so local script are rejected (and rightly so) but the error message (incorrect character line 1) is irrelevant.

Having been first mislead by the error message I eventually get to the root of the problem (about:blank) and decide to load instead a dummy HTML file from the local file system in order to seed the HTML document.

But the problem remains even with a local HTML instead of "about:blank", I still get the "incorrect character line 1" ("Caractere incorrect ligne 1" on my French Windows XP).

N.B : I get as many error messages (dialog boxes) as there are <script> statements in my HTML.

What happens next is IE complaining of an object being expected (in body.onload) whitch doesn't come a as a surprise since the script defining the object failed to load.
In the end I get a blank page.

Hope it helps. I'll do my best to answet more accurate questions if you have any.

P.S

I haven't installed IE7 on my development machine since it would make progress impossible.
Problem is I can't tell client to stick to IE6 ...






Re: Internet Explorer Web Development A problem with IWebBrowser2:Navigate() under IE7

Philippe LACHAISE

I tried another experiment with IE7 :

I saved the HTML source from my generated document and tried to load the file in IE7, I got the popup blocker !

It meand that IE7 is so paranoid that it will stop a local (same hard disk) HTML file from loading javascript files from the same local source !

I gess the same is happening whithin the webbrowser control.

Is there a way of telling IE7 : look, this local file does not come from the big bad outside world (internet zone), it can be trusted to know what it is doing, will you please leave its javascript alone




Re: Internet Explorer Web Development A problem with IWebBrowser2:Navigate() under IE7

Kun Cong - MSFT

Philippe,

Your issue is a common issue in IE7. You can refer to my reply in another thread to see the details:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1094782&SiteID=1&mode=1&PageID=1

In brief, I have two solutions:

  1. Add FEATURE_BLOCK_LMZ_SCRIPT key, and allow your application under this key. I don't know whether this could fix local intranet.
  2. A workaround made by me is making using of a dummy HTML containing a helper javascript function. Your application could invoke this JS function with the HTML source you want to insert, and let the function call document.write() for you. This could build correct context then your external script could be loaded.

This two solutions are described in detail in the previous link.





Re: Internet Explorer Web Development A problem with IWebBrowser2:Navigate() under IE7

AronRosenberg

Hi,

I am curious as to what you mean by your question regarding dialog popups.

Is the hosted control not allowed to use pop-ups/modal dialogs when hosting

the BrowserObj

Thanks!