How do I add a local script file to the HTML of a WebBrowser control?

后端 未结 4 1232
遥遥无期
遥遥无期 2020-12-06 02:34

This seems really dumb. I\'ve tried a bunch of different ways and it\'s just not working. I have a WinForms app with a WebBrowser control. If I try with a raw html file on m

4条回答
  •  我在风中等你
    2020-12-06 02:45

    There is a long story about workarounds of that "security fix" from MS. New behavior was implemented starting from IE7. Take a look into "base" tag and IE Feature controls.

    I did the following:

                        //TODO: if not mono
                    var executableFilename = Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location);
                    var keys = new[] { executableFilename, [vsname]+".vshost.exe" }; //check!
    
                    Action SetRegistryKeyOrFail =
                        (key, val, regStr) =>
                            {
                                var reg =
                                    Registry.CurrentUser.CreateSubKey(regStr);
                                if (reg == null) throw new Exception("Failed registry: " + regStr);
                                reg.SetValue(key, val);
                            };
    
                    foreach (var key in keys)
                    {
                        SetRegistryKeyOrFail(key, 1, @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BLOCK_LMZ_IMG");
                        SetRegistryKeyOrFail(key, 0, @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BLOCK_LMZ_SCRIPT");
                    }
    

提交回复
热议问题