whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

95 Visitors Online


 
...read values located in a a JavaScript?
Autor: Thorsten Sanders
Homepage: http://www.dasbinich.info
[ Print tip ]  

Tip Rating (9):  
     


// Just add a Webbrowser and two Buttons to the form and insert the following code

procedure TForm1.Button1Click(Sender: TObject);
begin
  
webbrowser1.Navigate('http://www.dasbinich.info/myred/delphi/index.html');
end;

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
  if 
(url = 'http://www.dasbinich.info/myred/delphi/index.html') then
    
ShowMessage('Value lautet: ' + webBrowser1.OleObject.Document.Forms.item
    ('test').Elements.item('testen').Value);
  //read the Javascript value testen of the form test
end;

//this is an example how to use it when there are no names
procedure TForm1.Button2Click(Sender: TObject);
begin
  
ShowMessage('Value lautet: ' + webBrowser1.OleObject.Document.Forms.item
  (0).Elements.item(0).Value);
end;


//to read the javascript value from a site with a frame use the following
webBrowser1.OleObject.Document.Frames.item('top').Document.Forms.item
('Countdown').Elements.item('Countdown').Value;
//top is the framename in this example


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners