Question : change function

hi experts, i want to change below click link function,
when click link i don't want open a new window ( _blank ), only opening own window ( _self ).
anyone help change below function or suggesting any other function?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
function WB_ClickLink(WB: TWebbrowser; const LinkText: string): Boolean;
var
  HTMLDocument2: IHTMLDocument2;
  links : IHTMLElementCollection;
  Element: IHTMLElement;
  href: OleVariant;
  I: Integer;
begin
  HTMLDocument2 := WB.Document as IHTMLDocument2;
  links:= HTMLDocument2.Links;
  for I := 0 to links.Length - 1 do
  begin
    Element:= HTMLDocument2.Links.Item(I, 0) as IHTMLElement;
    if AnsiContainsStr(Element.innerText, LinkText) or AnsiContainsStr(Element.getAttribute('href',0), LinkText) then
    begin
      Element.Click;
      Result:= True;
      Break;
    end;
  end;
  Result:= False;
end;

Answer : change function

Hi Gsamuk. Look here:

function WB_ClickLink(WB: TWebbrowser; const LinkText: string): Boolean;
var
  HTMLDocument2: IHTMLDocument2;
  links : IHTMLElementCollection;
  Element: IHTMLElement;
  href: OleVariant;
  I: Integer;
begin
  HTMLDocument2 := WB.Document as IHTMLDocument2;
  links:= HTMLDocument2.Links;
  for I := 0 to links.Length - 1 do
  begin
    Element:= HTMLDocument2.Links.Item(I, 0) as IHTMLElement;
    if AnsiContainsStr(Element.innerText, LinkText) or AnsiContainsStr(Element.getAttribute('href',0), LinkText) then
    begin
      if AnsiContainsStr(Element.getAttribute('target',0), '_blank') then
        WB.Navigate(Element.getAttribute('href',0))
      else
        Element.Click;
      Result:= True;
      Break;
    end;
  end;
  Result:= False;
end;
Random Solutions  
 
programming4us programming4us