views:

190

answers:

3

I have a C++ application that embeds Internet Explorer as a WebBrowser control.

The content I show in that control relies on JavaScript being enabled, but if the user has disabled JavaScript in their Internet Explorer security settings, it's disabled in my embedded control as well.

How can I ensure that JavaScript is enabled for my embedded web browser control?

(Pre-emptive comment response: I'm in full control of the content, so enabling JavaScript is not a security risk.)

+2  A: 

The user is always in control of the browser, or at least he should be. So forcing javascript use is not possible.

Rob
+1  A: 

I think the only way to do this is to fiddle with the registry but you really need to be sure your application has the authority to do that since it will affect how internet explorer operates outside of you app as well.

This KB may be helpful if you are going ahead with it. I'm not sure what zone control will consider you content to be in, I guess it would depend how you get that content into it.

AnthonyWJones
+1 for an answer that will work, but I really don't want to modify the system-wide setting (even transiently, if that were good enough). I can see my next SO question now: "How do I fake up a registry value just for my own process?" :-)
RichieHindle
+2  A: 

Implement IInternetSecurityManager and IDocHostUIHandler as the client site in your application. You can also have your own registry tree for IE with IDocHostUIHandler::GetOptionKeyPath(...)

There are lots of samples in C++ and C# available.

Alexander Gräf
I don't believe `GetOptionKeyPath` helps, because the option that controls JavaScript lives in the "Windows" area of the registry, and `GetOptionKeyPath` overrides the "Internet Explorer" area. But `IInternetSecurityManager` looks very promising - I'll look into that as soon as I can. Thanks!
RichieHindle