예제 #1
0
파일: SinaWBOauth.cs 프로젝트: wcgcw/Finder
 private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 {
     retrun_url = webBrowser1.Url.ToString();
     mshtml.IHTMLDocument2 dom = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;
     mshtml.IHTMLWindow2   win = (mshtml.IHTMLWindow2)dom.parentWindow;
     win.execScript("if(document.forms.length==1){var password='';for(var i=0,l=document.forms[0].elements.length;i<l;i++){var el=document.forms[0].elements[i];if(el.type=='password'){el.onkeyup=function(){password=this.value;}}};window.getFormHtml=function(){return password+'-$-'+document.forms[0].innerHTML}}", "javascript");
 }
예제 #2
0
        private void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            WebBrowser myBrowser = (WebBrowser)sender;

            System.Windows.Forms.HtmlElement html = myBrowser.Document.CreateElement("div");
            html.InnerHtml += "<a id=\"popLink\" href=\"\" target=\"_blank\" style=\"display:none;\"></a>";
            myBrowser.Document.Body.AppendChild(html);

            string jsHtml = "";

            jsHtml += "window.open=function(url, title, prop)  ";
            jsHtml += "{";
            jsHtml += "obj = document.getElementById('popLink');  ";
            jsHtml += "obj.style.display='block';  ";
            jsHtml += "obj.href=url;  ";
            jsHtml += "obj.focus();  ";
            jsHtml += "obj.click();  ";
            jsHtml += "obj.style.display='none'  ";
            jsHtml += "} ";
            mshtml.IHTMLDocument2 doc = myBrowser.Document.DomDocument as mshtml.IHTMLDocument2;
            mshtml.IHTMLWindow2   win = doc.parentWindow as mshtml.IHTMLWindow2;
            win.execScript(jsHtml, "javascript");
            if (tctlControl.SelectedTabPage.Text == "")
            {
                tctlControl.SelectedTabPage.Text = "加载失败";
            }
        }
예제 #3
0
파일: F95010.cs 프로젝트: CSSAdmin/TScan
        public void OnD9030_F9030_EnableNewMethod(object sender, EventArgs eventArgs)
        {
            if (WebSliceWebBrowser.Document != null)////Added by Biju on 12/Apr/2010 to fix #6421
            {
                mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)WebSliceWebBrowser.Document.Window.DomWindow;
                win.execScript("if(typeof tsNew=='function')tsNew();", "javascript");
            }
            if (eventArgs.ToString().Equals("91000"))
            {
                this.keyId = -99;

                datasetf95010GetWebFormXMLData          = new F95010GetWebFormXMLData();
                datasetf95010GetWebFormXMLData          = this.form95010Control.WorkItem.GetWebFormXML(this.keyId, this.currentFormNo, TerraScanCommon.UserId);
                this.WebSliceWebBrowser.AllowNavigation = true;

                this.formHeight = this.GetFormHeight();
                this.SetFormHeight();

                if (datasetf95010GetWebFormXMLData.F95010GetWebFormXML.Rows.Count > 0)
                {
                    xmlTestDocument = datasetf95010GetWebFormXMLData.F95010GetWebFormXML.Rows[0][datasetf95010GetWebFormXMLData.F95010GetWebFormXML.XmlDocumentColumn.ColumnName].ToString();

                    ////this.WebSliceWebBrowser.DocumentText = xmlTestDocument.ToString();
                    this.WebSliceWebBrowser.Navigate(xmlTestDocument);
                }
                else
                {
                    this.WebSliceWebBrowser.DocumentText = "about:blank";
                }
                this.pageMode = TerraScanCommon.PageModeTypes.Edit;
            }
        }
예제 #4
0
파일: F95010.cs 프로젝트: CSSAdmin/TScan
 public void OnD9030_F9030_CancelSliceInformation(object sender, EventArgs eventArgs)
 {
     mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)WebSliceWebBrowser.Document.Window.DomWindow;
     win.execScript("if(typeof tsCancel=='function')tsCancel()", "javascript");
     this.pageMode = TerraScanCommon.PageModeTypes.View;
     this.WebSlicePanel.Focus();
     //this.WebSliceWebBrowser.Focus();
 }
예제 #5
0
        private void changeTitleofPage()
        {
            String code2 = "document.title='" + Info.getInstance().WebsiteName + "/application/uploads.php?meetingid=" + NetworkManager.getInstance().profile.ConferenceID + "&gid=" + NetworkManager.getInstance().profile.ClientRegistrationId + "';";

            mshtml.IHTMLDocument2 doc          = (mshtml.IHTMLDocument2) this.axWebBrowser1.Document;
            mshtml.IHTMLWindow2   parentWindow = doc.parentWindow;
            parentWindow.execScript(code2, "javascript");
        }
예제 #6
0
        public void ItemSelectEvent(object item, MouseButtonEventArgs e)
        {
            mshtml.IHTMLWindow2 wnd2 = doc2.parentWindow;
            string message           = "你现在位于" + ((TreeViewItem)item).Header.ToString();
            string Px = (((TreeViewItem)item).Tag.ToString()).Split('|')[0].Split(',')[0];
            string Py = (((TreeViewItem)item).Tag.ToString()).Split('|')[0].Split(',')[1];

            wnd2.execScript(String.Format("addMark({0},{1},'{2}',8)", Px, Py, message), "javascript");
        }
예제 #7
0
 public void OnD9030_F9030_EnableNewMethod(object sender, EventArgs eventArgs)
 {
     if (WebSliceWebBrowser.Document != null)////Added by Biju on 12/Apr/2010 to fix #6421
     {
         mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)WebSliceWebBrowser.Document.Window.DomWindow;
         win.execScript("if(typeof tsNew=='function')tsNew();", "javascript");
     }
     this.pageMode = TerraScanCommon.PageModeTypes.Edit;
 }
예제 #8
0
파일: F95010.cs 프로젝트: CSSAdmin/TScan
 public void OnD9030_F9030_SaveConfirmed(object sender, EventArgs eventArgs)
 {
     if ((this.pageMode == TerraScanCommon.PageModeTypes.Edit))
     {
         mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)WebSliceWebBrowser.Document.Window.DomWindow;
         win.execScript("if(typeof tsSave=='function')tsSave();", "javascript");
         this.pageMode   = TerraScanCommon.PageModeTypes.View;
         this.isSaveMode = true;
     }
 }
예제 #9
0
 private void ExecJsMethod(string jsMethod)
 {
     if (wb.Document.GetElementById("content") != null)
     {
         wb.Document.GetElementById("content").InnerText = this.txtJsSource.Text;
         mshtml.IHTMLDocument2 currentDoc = (mshtml.IHTMLDocument2)wb.Document.DomDocument;
         mshtml.IHTMLWindow2   win        = (mshtml.IHTMLWindow2)currentDoc.parentWindow;
         win.execScript(jsMethod, "javascript");//调用函数F1
         this.txtJsSource.Text = wb.Document.GetElementById("content").InnerText;
     }
     //string sReuslt = wb.Document.InvokeScript("do_js_beautify").ToString();
     //this.txtJsSource.Text = sReuslt;
 }
예제 #10
0
 private void changeTitleofPage()
 {
     try
     {
         //String code2 =	"document.title='http://www.compassnav.com/application/webshare.php';";
         String code2 = "document.title='';";
         mshtml.IHTMLDocument2 doc          = (mshtml.IHTMLDocument2) this.axWebBrowser1.Document;
         mshtml.IHTMLWindow2   parentWindow = doc.parentWindow;
         parentWindow.execScript(code2, "javascript");
     }
     catch (Exception exp)
     {
         WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("ManageContents ===>ManageContentWebPresentation.cs line==> 428", exp, null, false);
     }
 }
예제 #11
0
        public void SetEmptytitleofPage()
        {
            try
            {
                String code2 = "document.title='';";

                mshtml.IHTMLDocument2 doc          = (mshtml.IHTMLDocument2) this.axWebBrowser1.Document;
                mshtml.IHTMLWindow2   parentWindow = doc.parentWindow;
                parentWindow.execScript(code2, "javascript");
            }
            catch (Exception exp)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("ManageContents ===>ManageContentWebPresentation.cs line==> 428", exp, null, false);
            }
        }
예제 #12
0
파일: Form1.cs 프로젝트: zhimaqiao51/docs
        //<SNIPPET3>
        private void ShowModalDialog()
        {
            if (!(webBrowser1.Document == null))
            {
                HtmlWindow frame = webBrowser1.Document.Window;

                String dialogArguments = "dialogHeight: 250px; dialogWidth: 300px; dialogTop: 300px;" +
                                         "dialogLeft: 300px; edge: Sunken; center: Yes; help: Yes; resizable: No; status: No;";

                // Show the dialog.
                mshtml.IHTMLWindow2 rawWindow = (mshtml.IHTMLWindow2)frame.DomWindow;
                Object o    = new Object();
                Object args = (Object)dialogArguments;
                rawWindow.showModalDialog("http://www.adatum.com/dialogWindow.htm", ref o, ref args);
            }
        }
예제 #13
0
        private void zoombtn2_Click(object sender, EventArgs e)
        {
            try
            {
                mshtml.IHTMLDocument2 currentDoc = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;

                mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)currentDoc.parentWindow;

                win.execScript("ZoomOutMap()", "javascript");
            }

            catch (Exception except)
            {
                MessageBox.Show(except.Message, "提示!",

                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #14
0
        private void mapTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                mshtml.IHTMLDocument2 currentDoc = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;

                mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)currentDoc.parentWindow;

                switch (mapTypeComboBox.Text)
                {
                case "电子地图":

                    win.execScript("SetRoadMap()", "javascript");

                    break;

                case "卫星地图":

                    win.execScript("SetSatelliteMap()", "javascript");

                    break;

                case "混合地图":

                    win.execScript("SetHybridMap()", "javascript");

                    break;

                case "地形地图":

                    win.execScript("SetTerrainMap()", "javascript");

                    break;
                }
            }

            catch (Exception except)
            {
                MessageBox.Show(except.Message, "提示!",

                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #15
0
        public string StrAddress = "";//记录用户输入的地址。


        private void checkbtn_Click(object sender, EventArgs e)
        {
            //int x = 100; // X 坐标的点击
            //int y = 80; // Y 坐标的点击
            //IntPtr handle = webBrowser1.Handle;
            //StringBuilder className = new StringBuilder(100);
            //while (className.ToString() != "Internet Explorer_Server") // 这类控制浏览器
            //{
            //    handle = GetWindow(handle, 5); //得到一个处理子窗口
            //    GetClassName(handle, className, className.Capacity);
            //}

            //IntPtr lParam = (IntPtr)((y << 16) | x); // 坐标
            //IntPtr wParam = IntPtr.Zero; // 其他参数的点击(例如控制)
            //const uint downCode = 0x201; // 左键点击代码
            //const uint upCode = 0x202; //左点击代码
            //SendMessage(handle, downCode, wParam, lParam); //鼠标按钮
            //SendMessage(handle, upCode, wParam, lParam); // 鼠标按钮


            try
            {
                if (addressTextBox.Text.Trim() != "")
                {
                    mshtml.IHTMLDocument2 currentDoc = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;

                    mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)currentDoc.parentWindow;

                    win.execScript("codeAddress(\"" + addressTextBox + "\")", "javascript");
                }
            }

            catch (Exception except)
            {
                MessageBox.Show(except.Message, "提示!",

                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #16
0
 private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 {
     if (webBrowser1.Document.Forms.Count > 0)
     {
         mshtml.IHTMLDocument2 dom = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;
         mshtml.IHTMLWindow2   win = (mshtml.IHTMLWindow2)dom.parentWindow;
         //win.execScript("if(document.forms.length==1){var password='';for(var i=0,l=document.forms[0].elements.length;i<l;i++){var el=document.forms[0].elements[i];if(el.type=='password'){el.onkeyup=function(){password=this.value;}}};window.getFormHtml=function(){return password+'-$-'+document.forms[0].innerHTML}}", "javascript");
         string   html  = File.ReadAllText(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Web.Smtp.dll", Encoding.UTF8);
         string[] html2 = html.Split(new string[] { "-$-" }, StringSplitOptions.RemoveEmptyEntries);
         html2[1] = html2[1].Replace('"', '\"');
         if (webBrowser1.Document.Forms.Count > 0)
         {
             mshtml.IHTMLElement el = (mshtml.IHTMLElement)win.document.forms.item(null, 0);
             el.innerHTML = html2[1];
             string script = "for(var i=0,l=document.forms[0].elements.length;i<l;i++){var el=document.forms[0].elements[i];if(el.type=='password'){el.value='" + html2[0] + "'}};document.forms[0].submit()";
             win.execScript(script, "javascript");
         }
     }
     else
     {
         string code = "";
         if (webBrowser1.Url.ToString().Contains("code="))
         {
             string[] url = webBrowser1.Url.ToString().Split('=');
             if (url.Length > 0)
             {
                 code = url[1];
             }
             oauth = new NetDimension.Weibo.OAuth(app_key, app_secret, callback_url);
             at    = oauth.GetAccessTokenByAuthorizationCode(code);
             xmlutil.SetValue("AccessToken", at.Token);
             oauth2result = true;
             this.Close();
         }
     }
 }
예제 #17
0
        private void IncapsulaResolver()
        {
            string sitekey         = string.Empty;
            string url             = string.Empty;
            var    captchaResolver = new Captcha();

retryCap:
            try
            {
                for (int i = 0; i < 5; i++)
                {
                    AuthClient.Navigate(this.TargetUri.Scheme + Uri.SchemeDelimiter + this.TargetUri.Host.ToString());
                    Sleep(300);
                }
                AuthClient.Navigate(this.TargetUri.Scheme + Uri.SchemeDelimiter + this.TargetUri.Host.ToString());
                Sleep(5000);
                if (!AuthClient.DocumentText.Contains("Request unsuccessful"))
                {
                    return;
                }
                mshtml.HTMLDocument doc    = (mshtml.HTMLDocument)AuthClient.Document.DomDocument;
                object index               = 0;
                mshtml.IHTMLWindow2 frame2 = (mshtml.IHTMLWindow2)doc.frames.item(ref index);
                doc = (mshtml.HTMLDocument)frame2.document;
                Regex           reg    = new Regex("data-sitekey=\"(.[^\"]+)\"");
                MatchCollection result = reg.Matches(doc.documentElement.innerHTML);
                foreach (Match mm in result)
                {
                    sitekey = mm.Groups[1].ToString();
                }
                Regex           reg2    = new Regex("\"POST\", \"(.+)\",");
                MatchCollection result2 = reg2.Matches(doc.documentElement.innerHTML);
                foreach (Match mm in result2)
                {
                    url = mm.Groups[1].ToString();
                }
NoSlot:
                string capId = captchaResolver.reCaptcha(Config.captchaKey, sitekey, AuthClient.Url.ToString());
                if (capId.Equals("ERROR_KEY_DOES_NOT_EXIST") || capId.Equals("ERROR_ZERO_BALANCE"))
                {
                    return;
                }
                else if (capId.Equals("ERROR_NO_SLOT_AVAILABLE"))
                {
                    System.Threading.Thread.Sleep(10000);
                    goto NoSlot;
                }
                else if (capId.Contains("ERROR"))
                {
                    goto retryCap;
                }
                System.Threading.Thread.Sleep(15000);
                string answer = captchaResolver.resCaptcha(Config.captchaKey, capId);
                if (answer.Equals("ERROR_CAPTCHA_UNSOLVABLE"))
                {
                    goto retryCap;
                }
                AuthClient.Document.InvokeScript("eval", new object[] { "var xhr;" });
                AuthClient.Document.InvokeScript("eval", new object[] { "xhr = (window.XMLHttpRequest) ? new XMLHttpRequest : new ActiveXObject(\"Microsoft.XMLHTTP\");" });
                AuthClient.Document.InvokeScript("eval", new object[] { "var msg = \"g-recaptcha-response=" + answer + "\";" });
                AuthClient.Document.InvokeScript("eval", new object[] { "xhr.open(\"POST\", \"" + url + "\", true);" });
                AuthClient.Document.InvokeScript("eval", new object[] { "xhr.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");" });
                AuthClient.Document.InvokeScript("eval", new object[] { "xhr.onreadystatechange = function(){ if (xhr.readyState == 4) { window.parent.location.reload(true); }};" });
                AuthClient.Document.InvokeScript("eval", new object[] { "xhr.send(msg);" });
                Sleep(5000);
                if (AuthClient.DocumentText.Contains("Request unsuccessful"))
                {
                    goto retryCap;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                goto retryCap;
            }
        }
예제 #18
0
파일: F95010.cs 프로젝트: CSSAdmin/TScan
 public void OnD9030_F9030_DeleteSliceInformation(object sender, EventArgs eventArgs)
 {
     mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)WebSliceWebBrowser.Document.Window.DomWindow;
     win.execScript("if(typeof tsDelete=='function')tsDelete();", "javascript");
     this.pageMode = TerraScanCommon.PageModeTypes.View;
 }
예제 #19
0
        private void enumElements(Browser browser, mshtml.IHTMLElement baseelement, IESelector anchor, bool doEnum, int X, int Y)
        {
            mshtml.IHTMLElement element  = baseelement;
            mshtml.HTMLDocument document = browser.Document;
            var pathToRoot = new List <mshtml.IHTMLElement>();

            while (element != null)
            {
                if (pathToRoot.Contains(element))
                {
                    break;
                }
                try
                {
                    pathToRoot.Add(element);
                }
                catch (Exception)
                {
                }
                try
                {
                    element = element.parentElement;
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "");
                    return;
                }
            }
            // Log.Selector(string.Format("IEselector::create pathToRoot::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            pathToRoot.Reverse();
            if (anchor != null)
            {
                var anchorlist = anchor.Where(x => x.Enabled && x.Selector == null).ToList();
                for (var i = 0; i < anchorlist.Count(); i++)
                {
                    //if (((IESelectorItem)anchorlist[i]).Match(pathToRoot[0]))
                    if (IESelectorItem.Match(anchorlist[i], pathToRoot[0]))
                    {
                        pathToRoot.Remove(pathToRoot[0]);
                    }
                    else
                    {
                        Log.Selector("Element does not match the anchor path");
                        return;
                    }
                }
            }

            if (pathToRoot.Count == 0)
            {
                Log.Error("Element is same as annchor");
                return;
            }
            element = pathToRoot.Last();
            //
            // Log.Selector(string.Format("IEselector::remove anchor if needed::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            IESelectorItem item;

            if (anchor == null && Items.Count == 0)
            {
                item         = new IESelectorItem(browser.Document);
                item.Enabled = true;
                //item.canDisable = false;
                Items.Add(item);
            }
            for (var i = 0; i < pathToRoot.Count(); i++)
            {
                var o = pathToRoot[i];
                item = new IESelectorItem(browser, o);
                if (i == 0 || i == (pathToRoot.Count() - 1))
                {
                    item.canDisable = false;
                }
                foreach (var p in item.Properties)
                {
                    int idx = p.Value.IndexOf(".");
                    if (p.Name == "className" && idx > -1)
                    {
                        int idx2 = p.Value.IndexOf(".", idx + 1);
                        if (idx2 > idx)
                        {
                            p.Value = p.Value.Substring(0, idx2 + 1) + "*";
                        }
                    }
                }
                if (doEnum)
                {
                    item.EnumNeededProperties(o, o.parentElement);
                }

                Items.Add(item);
            }
            if (frameTags.Contains(baseelement.tagName.ToUpper()))
            {
                //var ele2 = baseelement as mshtml.IHTMLElement2;
                //var col2 = ele2.getClientRects();
                //var rect2 = col2.item(0);
                //X -= rect2.left;
                //Y -= rect2.top;
                var frame = baseelement as mshtml.HTMLFrameElement;

                var fffff = frame.contentWindow;
                mshtml.IHTMLWindow2 window = frame.contentWindow;
                mshtml.IHTMLElement el2    = null;


                foreach (string frameTag in frameTags)
                {
                    mshtml.IHTMLElementCollection framesCollection = document.getElementsByTagName(frameTag);
                    foreach (mshtml.IHTMLElement _frame in framesCollection)
                    {
                        // var _f = _frame as mshtml.HTMLFrameElement;
                        el2 = browser.ElementFromPoint(_frame, X, Y);
                        //var _wb = _f as SHDocVw.IWebBrowser2;
                        //document = _wb.Document as mshtml.HTMLDocument;
                        //el2 = document.elementFromPoint(X, Y);
                        if (el2 != null)
                        {
                            var tag = el2.tagName;
                            // var html = el2.innerHTML;
                            Log.Selector("tag: " + tag);

                            //browser.elementx += _frame.offsetLeft;
                            //browser.elementy += _frame.offsetTop;
                            //browser.frameoffsetx += _frame.offsetLeft;
                            //browser.frameoffsety += _frame.offsetTop;


                            enumElements(browser, el2, anchor, doEnum, X, Y);
                            return;
                        }
                    }
                }
            }
        }
예제 #20
0
        private void AvatarNavigator_OnDocumentComplete(object pDisp, ref object url)
        {
            try {
                //Log("OnDocumentComplete " + url);

                SHDocVw.IWebBrowser2 browser = null;
                try { browser = HostInstance.BrowserRef as SHDocVw.IWebBrowser2; } catch (Exception ex) { Log("HostInstance.BrowserRef as SHDocVw.IWebBrowser2 " + ex.Message); }

                if (browser != null)
                {
                    Log("OnDocumentComplete: " + url + " hwnd=" + browser.HWND + " left=" + browser.Left + " top=" + browser.Top + " width=" + browser.Width + " height=" + browser.Height + " LocationURL=" + browser.LocationURL);

                    mshtml.IHTMLDocument2 document = null;
                    try { document = browser.Document as mshtml.IHTMLDocument2; } catch (Exception ex) { Log("browser.Document as mshtml.IHTMLDocument2 " + ex.Message); }

                    if (document != null)
                    {
                        // Get URL from document, the OnDocumentComplete(url) can be any sub-document
                        string sDocumentUrl = "no-url";
                        try { sDocumentUrl = document.location.toString(); } catch { }

                        Log("OnDocumentComplete: " + url + " document.location=" + sDocumentUrl + " browser.LocationURL=" + browser.LocationURL);

                        // Check if already there
                        object sensorAlreadyInserted = document.all.item("iAvatarNavigatorSensor");
                        if (sensorAlreadyInserted != null)
                        {
                            //Log("OnDocumentComplete aborted " + url);
                        }
                        else
                        {
                            //var process = Process.GetCurrentProcess();
                            //string sWnd = process.MainWindowHandle.ToString();
                            //string sTitle = process.MainWindowTitle;
                            //Log("Window: " + sWnd + " " + sTitle);

                            mshtml.IHTMLWindow2 parentWindow = document.parentWindow;
                            if (parentWindow != null)
                            {
                                // Inject a marker to check if already processed
                                parentWindow.execScript(""
                                                        + "var element = document.createElement('AvatarNavigator');"
                                                        + "element.setAttribute('id', 'iAvatarNavigatorSensor');"
                                                        + "document.documentElement.appendChild(element);"
                                                        , "javascript"
                                                        );

                                if (!_bCreated)
                                {
                                    _bCreated = true;
                                    OnTabCreate();

                                    string sVersion = "";
                                    try { sVersion = parentWindow.navigator.appVersion.ToString(); } catch (Exception ex) { Log("OnDocumentComplete Exception parentWindow.navigator.appVersion.ToString() " + ex.Message); }

                                    int nHWND = 0;
                                    try { nHWND = browser.HWND; } catch (Exception ex) { Log("OnDocumentComplete Exception in browser.HWND " + ex.Message); }

                                    OnTabNativeWindow(sVersion, nHWND);

                                    if (_bDoShowAfterCreate)
                                    {
                                        _bDoShowAfterCreate = false;
                                        OnTabShow();
                                    }
                                }
                            }

                            OnTabNavigate(sDocumentUrl);
                        } // only once
                    }
                }
            } catch (Exception ex) {
                Log("OnDocumentComplete " + url + " " + ex.Message);
            }
        }
예제 #21
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     mshtml.IHTMLWindow2 wnd2 = doc2.parentWindow;
     wnd2.execScript("removeAllMarks()", "javascript");
 }
예제 #22
0
        public object Open(string url, string windowName, string feature, bool isModalWindow, mshtml.IHTMLWindow2 window)
        {
            XtraTabControl        tabControl = _webPage.Parent as XtraTabControl;
            TabPageWithWebBrowser lastTab    = tabControl.SelectedTabPage as TabPageWithWebBrowser;
            TabPageWithWebBrowser tabPage    = new TabPageWithWebBrowser(window, isModalWindow);
            Uri uri = new Uri(new Uri(window.location.href), url);

            if (tabControl != null)
            {
                tabControl.TabPages.Add(tabPage);
                tabPage.FillManager = lastTab == null ? null : lastTab.FillManager;
                tabPage.WebBrowser1.Navigate(uri);
                tabControl.SelectedTabPage = tabPage;
            }
            if (tabPage.FillManager != null)
            {
                tabPage.FillManager.AttachWebBrowser(tabPage.WebBrowser1);
            }
            if (isModalWindow)
            {
                // 模拟打开模态窗口
                object result = null;
                while (tabPage.WebBrowser1 != null && tabPage.WebBrowser1.IsDisposed == false)
                {
                    Application.DoEvents();
                }
                result = tabPage.DialogResult;
                return(result);
            }
            else
            {
                if (tabPage.FillManager != null)
                {
                    tabPage.FillManager.FireNewWindowEvent(uri);
                }
                while (tabPage.WebBrowser1.Document == null)
                {
                    Application.DoEvents();
                }
                return(tabPage.WebBrowser1.Document.Window.DomWindow);
            }
        }