本文整理汇总了C#中IHTMLDocument2类的典型用法代码示例。如果您正苦于以下问题:C# IHTMLDocument2类的具体用法?C# IHTMLDocument2怎么用?C# IHTMLDocument2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHTMLDocument2类属于命名空间,在下文中一共展示了IHTMLDocument2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FCheckForControl
public static bool FCheckForControl(IHTMLDocument2 oDoc2, string sId)
{
if (oDoc2.all.item(sId, 0) != null)
return true;
return false;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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
{
}
}
示例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 ;
}
}
示例10: DocHTML
public DocHTML(HTMLDocument doc)
{
mDoc = doc;
mDoc2 = (IHTMLDocument2)mDoc;
mDoc3 = (IHTMLDocument3)mDoc;
mDoc4 = (IHTMLDocument4)mDoc;
mDoc5 = (IHTMLDocument5)mDoc;
}
示例11: UpdateDocumentEvents
public void UpdateDocumentEvents(IHTMLDocument2 document)
{
if (document != null)
{
//_document.MouseMove += new HtmlElementEventHandler(doc_MouseMove);
//_document.Click += new HtmlElementEventHandler(doc_Click);
}
}
示例12: IEDocument
public IEDocument(IHTMLDocument2 htmlDocument, IEElement containingFrameElement)
{
if (htmlDocument == null)
throw new ArgumentNullException("htmlDocument");
this.htmlDocument = htmlDocument;
this.containingFrameElement = containingFrameElement;
}
示例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;
}
示例14: FrameCollection
public FrameCollection(DomContainer domContainer, IHTMLDocument2 htmlDocument)
{
AllFramesProcessor processor = new AllFramesProcessor(domContainer, (HTMLDocument) htmlDocument);
NativeMethods.EnumIWebBrowser2Interfaces(processor);
elements = processor.elements;
}
示例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();
}