WEBBROWSER

Hi, I have a question about WebBrowser component on Delphi 5. is it possible to get WebSite Icon using WebBrowser component? Thank you
pedro8Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ivanov_GCommented:

  the icon is in the HTML document, so you can search for it...

   <link href="http://i.dirbg.com/dir.ico" rel="SHORTCUT ICON">
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shaneholmesCommented:

Check out the excepted anser to this post:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20793583.html?query=html+Element&searchType=topic

Modify it to parse for SHORTCUT ICON

Shane
0
Eddie ShipmanAll-around developerCommented:
Try this option...

function GetFavIcon(Doc:IHTMLDocument2):String;
var
  All: IHtmlElementCollection;
  E: IhtmlElement;
  Element: TElementInfo;
  x: INteger;
  ELink: IHTMLLinkElement;
  DocLoc: String;
begin
  DocLoc := Doc.location.toString;
  DocLoc := Copy(DocLoc, 1, Length(DocLoc)-1);
  All := Doc.Get_all;
  if (All <> nil) then
  begin
    for x := 0 to All.length - 1 do
    begin
      E := All.item(x, 0) as IHTMLElement;
      if E.tagName = 'LINK' then
      begin
        ELink := E as IHTMLLinkElement;
        if ( Pos('SHORTCUT', UpperCase(ELink.rel)) > 0 ) or
           ( Pos('ICON', UpperCase(ELink.rel)) > 0 )     then
          Result := DocLoc + ELink.href;
      end;
    end;
  end;
end;

procedure TForm1.WebBrowser1NavigateComplete2(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
  Label1.Caption := GetFavIcon(WebBrowser1.Document as IHTMLDocument2);
end;

However, since IE caches the FavIcon based upon the domain, not all pages
may have this particular link tag. I don't know about Mozilla, Netscape, etc...
0
Eddie ShipmanAll-around developerCommented:
add mshtml to your uses for D6+ or import MSHTML type library.
0
Eddie ShipmanAll-around developerCommented:
So, Pedro8, why have you not accepted the answer, yet?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.