• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IHTMLDocument2类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IHTMLDocument2的典型用法代码示例。如果您正苦于以下问题:C# IHTMLDocument2类的具体用法?C# IHTMLDocument2怎么用?C# IHTMLDocument2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IHTMLDocument2类属于命名空间,在下文中一共展示了IHTMLDocument2类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FCheckForControl

        public static bool FCheckForControl(IHTMLDocument2 oDoc2, string sId)
        {
            if (oDoc2.all.item(sId, 0) != null)
                return true;

            return false;
        }
开发者ID:rlittletht,项目名称:ArbWeb,代码行数:7,代码来源:ArbWebControl2.cs


示例2: ExtractEditUri

        /// <summary>
        /// Try to extract the EditUri (RSD file URI) from the passed DOM
        /// </summary>
        /// <param name="weblogDOM"></param>
        /// <returns></returns>
        private static string ExtractEditUri(string homepageUrl, IHTMLDocument2 weblogDOM)
        {
            // look in the first HEAD tag
            IHTMLElementCollection headElements = ((IHTMLDocument3)weblogDOM).getElementsByTagName("HEAD");
            if (headElements.length > 0)
            {
                // get the first head element
                IHTMLElement2 firstHeadElement = (IHTMLElement2)headElements.item(0, 0);

                // look for link tags within the head
                foreach (IHTMLElement element in firstHeadElement.getElementsByTagName("LINK"))
                {
                    IHTMLLinkElement linkElement = element as IHTMLLinkElement;
                    if (linkElement != null)
                    {
                        string linkRel = linkElement.rel;
                        if (linkRel != null && (linkRel.ToUpperInvariant().Equals("EDITURI")))
                        {
                            return UrlHelper.UrlCombineIfRelative(homepageUrl, linkElement.href);
                        }
                    }
                }
            }

            // couldn't find one
            return null;
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:32,代码来源:RsdServiceDetector.cs


示例3: WaitForFramesToComplete

        protected virtual void WaitForFramesToComplete(IHTMLDocument2 maindocument)
        {
            var mainHtmlDocument = UtilityClass.GetWithFailOver(() => (HTMLDocument)maindocument);

            var framesCount = FrameCountProcessor.GetFrameCountFromHTMLDocument(mainHtmlDocument);

            for (var i = 0; i != framesCount; ++i)
            {
                var frame = FrameByIndexProcessor.GetFrameFromHTMLDocument(i, mainHtmlDocument);

                if (frame == null) continue;

                IHTMLDocument2 frameDocument;
                try
                {
                    if (!WaitWhileIEBusy(frame))
                        continue;

                    if (!WaitWhileIEReadyStateNotComplete(frame))
                        continue;

                    WaitWhileFrameDocumentNotAvailable(frame);

                    frameDocument = (IHTMLDocument2)frame.Document;
                }
                finally
                {
                    // free frame
                    Marshal.ReleaseComObject(frame);
                }

                WaitWhileDocumentStateNotCompleteOrInteractive(frameDocument);
                WaitForFramesToComplete(frameDocument);
            }
        }
开发者ID:exaphaser,项目名称:WatiN,代码行数:35,代码来源:IEWaitForComplete.cs


示例4: TransformFormElements

        /// <summary>
        /// Transform each form element to a HtmlFormTag.
        /// </summary>
        /// <param name="htmlDoc"> The HTML DOM Document to process.</param>
        public static HtmlFormTagCollection TransformFormElements(IHTMLDocument2 htmlDoc, Uri currentUri)
        {
            // For each form, add in temp FormTags Collection
            FormConverter converter = new FormConverter();

            HtmlFormTagCollection formCollection = new HtmlFormTagCollection(htmlDoc.forms.length);

            try
            {
                foreach ( HTMLFormElementClass formElement in htmlDoc.forms )
                {
                    System.Windows.Forms.Application.DoEvents();

                    // Convert to HTML Form Tag
                    HtmlFormTag form = converter.ConvertToHtmlFormTag(formElement, currentUri);

                    if ( !formCollection.ContainsKey(form.Name) )
                    {
                        formCollection.Add(form.Name, form);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
                Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
            }

            return formCollection;
        }
开发者ID:molekilla,项目名称:Ecyware_GreenBlue_Inspector,代码行数:34,代码来源:HtmlDomTransformation.cs


示例5: GetCombinedUrl

        public static string GetCombinedUrl(IHTMLDocument2 docRoot, out int numOfDocs)
        {
            SortedDictionary<string, int> pageUrls = new SortedDictionary<string, int>();	// 중복삽입을 피하기 위해.
            string combinedUrl = "";

            IHTMLDocument2[] docs = ImgSrcExtractor.GetHtmlDocumentsByOle(docRoot);

            foreach (IHTMLDocument2 doc in docs)
            {
            //				Logger.DLog("page url found: {0}", doc.url);

                if (doc.url != "about:blank")
                {
                    if(!pageUrls.ContainsKey(doc.url))
                    {
                        pageUrls.Add(doc.url, 0);
                    }
                }
            }

            // combined url은 중복 삭제, 정렬 후 만든다.
            foreach(KeyValuePair<string, int> url in pageUrls)
            {
                combinedUrl += url.Key;
            }

            numOfDocs = pageUrls.Count;

            // 더이상 사용하지 않는다...
            numOfDocs = numOfDocs * 4 / 5;

            return combinedUrl;
        }
开发者ID:billzoo,项目名称:imageraker,代码行数:33,代码来源:AutoSaveManager.cs


示例6: Transform

		private static IHTMLDocument3 Transform( IHTMLDocument2 htmlDoc )
		{
			AddEmbeddedCSS( htmlDoc );
		
			// remove the onload InitTitle script call
			IHTMLBodyElement body = (IHTMLBodyElement)htmlDoc.body;
			body.onload = "";
			
			// because the scripts that insert the header and footer get
			// run when we load the source html, we remove them here
			// This also removes the dependency on having scripting enabled 
			// on client browsers for the online version
			foreach ( IHTMLDOMNode script in htmlDoc.scripts )
				script.parentNode.removeChild( script );

			IHTMLDocument3 doc3 = htmlDoc as IHTMLDocument3;
			Debug.Assert( doc3 != null );

			// fix up all of the hyper-links
			foreach ( IHTMLAnchorElement anchor in doc3.getElementsByTagName( "a" ) )
				Transform( anchor );

			// fix up all of the img tags
			foreach ( IHTMLImgElement img in doc3.getElementsByTagName( "img" ) )
				Transform( img );

			return doc3;
		}
开发者ID:tgassner,项目名称:NDoc,代码行数:28,代码来源:HtmlTransform.cs


示例7: TransformAnchorElements

        /// <summary>
        /// Transform anchor tags to HtmlAnchorTag.
        /// </summary>
        /// <param name="htmlDoc"> The HTML DOM Document to process.</param>
        /// <returns> A HtmlTagBaseList.</returns>
        public static HtmlTagBaseList TransformAnchorElements(IHTMLDocument2 htmlDoc)
        {
            HtmlTagBaseList list = new HtmlTagBaseList();

            foreach ( object obj in htmlDoc.links )
            {
                if ( obj is IHTMLAnchorElement )
                {
                    IHTMLAnchorElement a = (IHTMLAnchorElement)obj;
                    HtmlAnchorTag anchorTag = new HtmlAnchorTag();
                    anchorTag.HRef = a.href;
                    anchorTag.Host = a.host;
                    anchorTag.Hostname = a.hostname;
                    anchorTag.MimeType = a.mimeType;
                    anchorTag.Pathname = a.pathname;
                    anchorTag.Protocol = a.protocol;
                    anchorTag.Query = a.search;
                    list.Add(anchorTag);
                }
            //				else
            //				{
            //					System.Windows.Forms.MessageBox.Show(((mshtml.IHTMLElement)obj).outerHTML);
            //				}
            }

            return list;
        }
开发者ID:molekilla,项目名称:Ecyware_GreenBlue_Inspector,代码行数:32,代码来源:HtmlDomTransformation.cs


示例8: Filter

        public void Filter(ref IHTMLDocument2 inputHtmlDoc)
        {
            try
            {
                //Modify input HTML document iff formName is valid
                if ((scriptNameByUrl != null) && (scriptNameByUrl.Trim().Length != 0))
                {
                    string JScript = "var scriptElement = null;                                         " +
                                     "var allScripts = document.scripts;                                " +
                                     "for(var index = 0; index < allScripts.length; index++)            " +
                                     "{                                                                 " +
                                     "    scriptElement = allScripts[index];                            " +
                                     "    if (scriptElement.src.toString().indexOf('" + scriptNameByUrl + "') >=0)   " +
                                     "    {                                                             " +
                                     "        alert(scriptElement.parentNode);      " +
                                     "    }                                                             " +
                                     "}                                                                 ";

                    //Hide the form
                    inputHtmlDoc.parentWindow.execScript(JScript, "JavaScript");

                }
            }
            catch
            {

            }
            finally
            {

            }
        }
开发者ID:dbose,项目名称:raagahacker,代码行数:32,代码来源:JScriptFilter.cs


示例9: RefreshBehaviors

        public void RefreshBehaviors(IHTMLDocument2 document)
        {
            lock(this)
            {
                // get interface needed for element enumeration
                IHTMLDocument3 document3 = (IHTMLDocument3)document ;

                // build new list of active behaviors
                Hashtable newActiveBehaviors = new Hashtable();

                //register global behaviors
                IDictionaryEnumerator behaviorEnumerator = _globalElementBehaviors.GetEnumerator() ;
                while (behaviorEnumerator.MoveNext())
                {
                    string tagName = (string)behaviorEnumerator.Key  ;
                    foreach( IHTMLElement element in document3.getElementsByTagName(tagName))
                    {
                        // if the element is already assigned an active behavior then move it
                        if ( _activeBehaviors.ContainsKey(element) )
                        {
                            newActiveBehaviors[element] = _activeBehaviors[element] ;
                            _activeBehaviors.Remove(element);
                        }
                        else // otherwise create a new behavior and add it
                        {
                            HtmlEditorElementBehavior elementBehavior = (HtmlEditorElementBehavior)Activator.CreateInstance(
                                (Type)behaviorEnumerator.Value, new object[] { element, _editorContext}  ) ;
                            newActiveBehaviors[element] = elementBehavior ;
                        }
                    }
                }

                //register element behaviors
                behaviorEnumerator = _elementBehaviors.GetEnumerator() ;
                while (behaviorEnumerator.MoveNext())
                {
                    IHTMLElement element = (IHTMLElement)behaviorEnumerator.Key  ;
                    // if the element is already assigned an active behavior then move it
                    if ( _activeBehaviors.ContainsKey(element) )
                    {
                        newActiveBehaviors[element] = _activeBehaviors[element] ;
                        _activeBehaviors.Remove(element);
                    }
                    else // otherwise create a new behavior and add it
                    {
                        Debug.Fail("illegal state: element behavior is not in the _activeBehaviors table");
                    }
                }

                // all of the elements left in the activeBehaviors list are no longer in the document
                // so we should dispose and remove them from the list
                foreach ( HtmlEditorElementBehavior elementBehavior in _activeBehaviors.Values )
                    elementBehavior.DetachFromElement();
                _activeBehaviors.Clear();

                // swap for new list
                _activeBehaviors = newActiveBehaviors ;
            }
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:59,代码来源:HtmlEditorElementBehaviorManager.cs


示例10: DocHTML

 public DocHTML(HTMLDocument doc)
 {
     mDoc = doc;
     mDoc2 = (IHTMLDocument2)mDoc;
     mDoc3 = (IHTMLDocument3)mDoc;
     mDoc4 = (IHTMLDocument4)mDoc;
     mDoc5 = (IHTMLDocument5)mDoc;
 }
开发者ID:jpespartero,项目名称:WorldWind,代码行数:8,代码来源:DocHTML.cs


示例11: UpdateDocumentEvents

 public void UpdateDocumentEvents(IHTMLDocument2 document)
 {
     if (document != null)
     {
         //_document.MouseMove += new HtmlElementEventHandler(doc_MouseMove);
         //_document.Click += new HtmlElementEventHandler(doc_Click);
     }
 }
开发者ID:Alister742,项目名称:ParseKit,代码行数:8,代码来源:WebEventProvider.cs


示例12: IEDocument

        public IEDocument(IHTMLDocument2 htmlDocument, IEElement containingFrameElement)
        {
            if (htmlDocument == null)
                throw new ArgumentNullException("htmlDocument");

            this.htmlDocument = htmlDocument;
            this.containingFrameElement = containingFrameElement;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:8,代码来源:IEDocument.cs


示例13: Document

		/// <summary>
		/// Initializes a new instance of the <see cref="Document"/> class.
		/// Mainly used by WatiN internally.
		/// </summary>
		/// <param name="domContainer">The DOM container.</param>
		/// <param name="htmlDocument">The HTML document.</param>
		public Document(DomContainer domContainer, IHTMLDocument2 htmlDocument)
		{
			ArgumentRequired(domContainer, "domContainer");
			ArgumentRequired(htmlDocument, "htmlDocument");

			DomContainer = domContainer;
			this.htmlDocument = htmlDocument;
		}
开发者ID:pusp,项目名称:o2platform,代码行数:14,代码来源:Document.cs


示例14: FrameCollection

		public FrameCollection(DomContainer domContainer, IHTMLDocument2 htmlDocument)
		{
			AllFramesProcessor processor = new AllFramesProcessor(domContainer, (HTMLDocument) htmlDocument);

			NativeMethods.EnumIWebBrowser2Interfaces(processor);

			elements = processor.elements;
		}
开发者ID:pusp,项目名称:o2platform,代码行数:8,代码来源:FrameCollection.cs


示例15: WLWEditorContent

        /// <summary>
        /// initializes a class instance using the WLW editor handle to 
        /// obtain access to the current HTML document through IHTMLDocument2
        /// </summary>
        public WLWEditorContent(IntPtr wlwEditorHandle)
        {
            _owner = wlwEditorHandle;

            // Everything else in this class depends upon successful initialization of _htmlDocument
            _htmlDocument = WLWEditorContent.getHtmlDocument2(wlwEditorHandle);
            _anchorCollection = this.getAnchorCollection();
        }
开发者ID:xivSolutions,项目名称:StaticAnchorManager,代码行数:12,代码来源:WLWEditorContent.cs


示例16: GetButtonElementIndex

 public static int GetButtonElementIndex(IHTMLDocument2 doc, IHTMLElement ele, string itemName, string tagStr)
 {
     int num = 0;
     bool flag = false;
     if (ele != null)
     {
         ElementTag iD = ElementTag.ID;
         if ((tagStr != string.Empty) && (tagStr != ""))
         {
             iD = (ElementTag) WindowUtil.StringToInt(tagStr);
         }
         if (iD != ElementTag.ID)
         {
             IHTMLElementCollection o = (IHTMLElementCollection) doc.all.tags("input");
             foreach (IHTMLElement element in o)
             {
                 if ((IsElementMatchType(element, "submit") || IsElementMatchType(element, "button")) && IsElementMatch(element, iD, itemName, ""))
                 {
                     if (ele == element)
                     {
                         flag = true;
                         break;
                     }
                     num++;
                 }
             }
             if (o != null)
             {
                 Marshal.ReleaseComObject(o);
             }
             if (!flag)
             {
                 o = (IHTMLElementCollection) doc.all.tags("button");
                 foreach (IHTMLElement element2 in o)
                 {
                     if (IsElementMatch(element2, iD, itemName, ""))
                     {
                         if (ele == element2)
                         {
                             flag = true;
                             break;
                         }
                         num++;
                     }
                 }
                 if (o != null)
                 {
                     Marshal.ReleaseComObject(o);
                 }
             }
         }
     }
     if (!flag)
     {
         num = 0;
     }
     return num;
 }
开发者ID:purplecow,项目名称:AutoBroswer,代码行数:58,代码来源:HtmlUtil.cs


示例17: Htmlwysiwyg

        public Htmlwysiwyg()
        {
            InitializeComponent();
            _changed = false;
            try
            {
                if (HtmlRenderer.Document != null)
                {
                    _doc = (IHTMLDocument2) HtmlRenderer.Document.DomDocument;
                }
            }
            catch (Exception ex)
            {
                MessageDialog.Show
                    (
                        "htmlRenderer Exception  \r\n" + ex.InnerException,
                        "Error",
                        MessageDialog.MessageBoxButtons.Ok,
                        MessageDialog.MessageBoxIcon.Error,
                        "" + "\r\n" + ex.StackTrace);
            }
            if (_doc != null)
            {
                _doc.designMode = "On";
                while (_doc.body == null)
                {
                    Application.DoEvents();
                }
            }

            _custCtxMenu = new ContextMenuStrip();
            _custCtxMenu.Items.Add("&Copy");
            _custCtxMenu.Items.Add("&Cut");
            _custCtxMenu.Items.Add("&Paste");
            _custCtxMenu.ItemClicked += custCtxMenu_ItemClicked;
            try
            {
                if (HtmlRenderer.Document == null)
                {
                    return;
                }
                if (HtmlRenderer.Document.Body != null)
                {
                    HtmlRenderer.Document.Body.KeyDown += Body_KeyDown;
                }
                HtmlRenderer.Document.ContextMenuShowing += Document_ContextMenuShowing;
            }
            catch (Exception ex)
            {
                MessageDialog.Show
                    (
                        "htmlRenderer Exception  \r\n" + ex.InnerException,
                        "Error",
                        MessageDialog.MessageBoxButtons.Ok,
                        MessageDialog.MessageBoxIcon.Error,
                        "" + "\r\n" + ex.StackTrace);
            }
        }
开发者ID:Brett1981,项目名称:ReuseableClasses,代码行数:58,代码来源:Htmlwysiwyg.cs


示例18: Initialize

 public void Initialize(ISpellingChecker spellingChecker, MshtmlControl mshtmlControl,
     IHTMLDocument2 htmlDocument, ReplaceWord replaceWordFunction, MarkupRangeFilter filter, DamageFunction damageFunction)
 {
     _spellingChecker = spellingChecker;
     _mshtmlControl = mshtmlControl;
     _htmlDocument = htmlDocument;
     _filter = filter;
     _replaceWordFunction = replaceWordFunction;
     _damageFunction = damageFunction;
 }
开发者ID:igoravl,项目名称:OpenLiveWriter,代码行数:10,代码来源:SpellingManager.cs


示例19: GetHtmlDocumentsByOle

        // document를 일반적으로 가져올 수 없는 경우 (security issue) 이렇게 가져옴.
        public static IHTMLDocument2[] GetHtmlDocumentsByOle(IHTMLDocument2 doc)
        {
            try
            {
                ExceptionTester.Instance.Throw("gethtmlbyole");

                List<IHTMLDocument2> docs = new List<IHTMLDocument2>();

                // add main doc
                docs.Add(doc);

                //get the OLE container from the window's parent
                IOleContainer oc = doc as IOleContainer;      //OC ALLOC

                //get the OLE enumerator for the embedded objects
                int hr = 0;
                IEnumUnknown eu;
                hr = oc.EnumObjects(tagOLECONTF.OLECONTF_EMBEDDINGS, out eu); //EU ALLOC

                Guid IID_IWebBrowser2 = typeof(SHDocVw.IWebBrowser2).GUID;
                object pUnk = null;
                int fetched = 0;
                const int MAX_FETCH_COUNT = 1;

                for (int i = 0; eu.Next(MAX_FETCH_COUNT, out pUnk, out fetched) == hr; i++)
                {
                    //QI pUnk for the IWebBrowser2 interface
                    SHDocVw.IWebBrowser2 brow = pUnk as SHDocVw.IWebBrowser2;

                    if (brow != null)
                    {
                        IHTMLDocument2 d = brow.Document as IHTMLDocument2;
                        //	Logger.Log("wb found. doc's url: {0}", d.url);

                        // if we found document, repeat recursively
                        IHTMLDocument2[] docs2 = GetHtmlDocumentsByOle(d);

                        foreach (IHTMLDocument2 doc2 in docs2)
                        {
                            docs.Add(doc2);
                        }
                    }
                }

                Marshal.ReleaseComObject(eu);                                 //EU FREE

                return docs.ToArray();
            }
            catch (Exception e)
            {
                Logger.Warn("cannt get html doc by ole! {0}", e.Message);

                return new IHTMLDocument2[] { };
            }
        }
开发者ID:billzoo,项目名称:imageraker,代码行数:56,代码来源:ImgSrcExtractor.cs


示例20: IsDocumentEqual

 public static bool IsDocumentEqual(IHTMLDocument2 doc1, IHTMLDocument2 doc2)
 {
     try
     {
         return Marshal.GetIUnknownForObject(doc1) == Marshal.GetIUnknownForObject(doc2);
     }
     catch
     {
         return false;
     }
 }
开发者ID:coastcdl,项目名称:autotester,代码行数:11,代码来源:HTMLAsstFunctions.cs



注:本文中的IHTMLDocument2类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IHTMLElement类代码示例发布时间:2022-05-24
下一篇:
C# IGumpWriter类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap