Пример #1
0
        protected void OnBeforeNewWindow(string url, out bool cancel, ref object ppDisp)
        {
            EventHandler <WebBrowserExtendedNavigatingEventArgs> h = BeforeNewWindow;
            WebBrowserExtendedNavigatingEventArgs args             = new WebBrowserExtendedNavigatingEventArgs(url, null);

            if (null != h)
            {
                h(this, args);
                ppDisp = args.ppDisp;
            }
            cancel = args.Cancel;
        }
Пример #2
0
        protected void OnBeforeNavigate(string url, string frame, out bool cancel)
        {
            EventHandler <WebBrowserExtendedNavigatingEventArgs> h = BeforeNavigate;
            WebBrowserExtendedNavigatingEventArgs args             = new WebBrowserExtendedNavigatingEventArgs(url, frame);

            if (null != h)
            {
                h(this, args);
            }
            //Pass the cancellation chosen back out to the events
            cancel = args.Cancel;
            if (url.ToLower().StartsWith("javascript:"))
            {
                string js = url.Substring("javascript:".Length);
                if (js.Length == 0 || js.ToLower() == "void" || js.ToLower().StartsWith("void("))
                {
                    cancel = true;
                    return;
                }
            }
        }