GeckoFX ObjectForScripting,GeckoFX 下js调用c#方法

GeckoFX ObjectForScripting,GeckoFX 下js调用c#方法

后台注册:

var subtitleWebBrowser = new GeckoWebBrowser();

subtitleWebBrowser.AddMessageEventListener("callMe", CallMe);
private void CallMe(string message)
{

}

  

GeckoFX内打开的HTML页面:

<script type='text/javascript'>
        window.onload= function() {
            var event = document.createEvent('MessageEvent');
            var origin = window.location.protocol + '//' + window.location.host;
            event.initMessageEvent ('callMe', true, true, 'some data', origin, 1234, window, null);
            document.dispatchEvent (event);
        }
    </script>
原文地址:https://www.cnblogs.com/nopassword/p/7522227.html