如何获取TWebBrowser控件的超级链接

2016-02-19 21:31 4 1 收藏

下面是个超简单的如何获取TWebBrowser控件的超级链接教程,图老师小编精心挑选推荐,大家行行好,多给几个赞吧,小编吐血跪求~

【 tulaoshi.com - 编程语言 】

  procedure getAllLinks2(WB: TWebBrowser; var InnerText,Links: TStringList);
  //needs unit as :shDocVw,Classes,MSHTML,variants
  var
  Htmldoc     : IHtmlDocument2;
  AllLinks    : IhtmlElementCollection;
  Len,I   : Integer;
  //HtmlItem2    : Olevariant;
  HtmlItem: IHTMLElement;

  begin
   HtmlDoc := WB.document as Ihtmldocument2;
  // AllLinks := HtmlDoc.get_links;
   AllLinks := HtmlDoc.links;
   Len := AllLinks.length ;
   Links.BeginUpdate;
   Innertext.BeginUpdate;
   For I :=0 To Len-1 do
   begin
   //HtmlItem2 := AllLinks.item(I,emptyparam);
   HtmlItem := AllLinks.item(I,emptyparam) as IHTMLElement;
   //StringList.Add(Htmlitem2.href);    //this is also a way to get the link

  
   {if trim(HtmlItem.innerHTML)'' then
   begin
   Links.Add(trim(HtmlItem.ToString));
   InnerText.Add(trim(HtmlItem.innerHTML));
   end;
   }

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

   if trim(HtmlItem.innerText)'' then
   begin
   Links.Add(trim(HtmlItem.ToString));
   InnerText.Add(trim(HtmlItem.Innertext));
   end;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

   end;
   Links.EndUpdate;
   InnerText.EndUpdate;
  end;

来源:https://www.tulaoshi.com/n/20160219/1626407.html

延伸阅读
标签: autocad教程
您正在看的AutoCAD教程是:超级链接的概念与使用。 超级链接简介     超级链接(Hyperlink)可以看作是一种文件的指针,它提供了相关联文件的路径,以指向在本地、网络驱动器或 Internet 上存储的文件,并可跳转到相应的文件;也可以在超级链接中指定跳转到文件中的一个命名位置,例如 AutoCAD中的一个视图或字处理程序中的...
标签: excel
如何批量删除Excel文档中的超级链接?   我们在对Excel表格进行操作的时候,经常发现有超级链接。但如果因为某种原因不想保留超级链接,就需要手动进行删除。如果要是只删除一个超级链接非常简单,将鼠标放到超级链接上,然后按鼠标右键,选择取消超链接即可(图1)。 但这种方法不能批量删除Excel文档中的超级链接,如果想将文档...
要向数据库中添加超级链接,要经过两个步骤,一是在表中定义字段类型为“超级链接”,一是向此字段中添加数据。 要在表中定义字段类型为“超级链接”,可以按下面的步骤操作: (1)打开数据库,选择要在“数据库”窗口中包含超级链接字段的表,单击“设计”按钮,进入设置窗口; (2)将光标移到“字段名称”栏中的一...
标签: ASP
  Code Title: Auto-linking Description: How would you like to have every instance of an http:// auto-hyperlink itself to the URL address that follows it? Well, here is a killer little function that will take every one of those that it finds in a string and sets up the hyperlink for you! Cool, eh? Copy and paste...
标签: 电脑入门
我们在对 Excel 表格进行操作的时候,经常发现有超级链接。但如果因为某种原因不想保留超级链接,就需要手动进行删除。如果要是只删除一个超级链接非常简单,将鼠标放到超级链接上,然后按鼠标右键,选择取消超链接即可(图1)。 但这种方法不能批量删除Excel文档中的超级链接,如果想将文档中的所有超级链接都删除,该如何处理?这里教给大家一...

经验教程

424

收藏

88
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部