Home > Back-end >  Urgent for Delphi7 call web JS function method
Urgent for Delphi7 call web JS function method

Time:10-01

How to call in rt, delphi7 JS function in web page, retrieve the function return value at the same time? thx

CodePudding user response:

Wb1: TWebBrowser;
Wb1. Navigate (URL);
In the event of an wb1DocumentComplete
Var
I: IHTMLDocument2;//need USES MSHTML
I:=wb1. Document as IHTMLDocument2;
By IHTMLDocument2 interface can get anything you want,

CodePudding user response:

CodePudding user response:

WebBrowser. OleObject. Document. ParentWindow. ExecScript (' Func_RedirectIndex () ', 'JavaScript');

Func_RedirectIndex () is that you will perform function, the execution is not return a value, if you need to return, such as with a way to try on the second floor,

CodePudding user response:

CodePudding user response:


The top

CodePudding user response:

pass by,

CodePudding user response:

Perform JS method:
WebBrowser1. OleObject. Document. ParentWindow. ExecScript (' MB () ', 'Javascript');//HTML - Js
Can write your own code, also can call the internal function,


To get js
Method 1:

On js, js, results in a global javascript variables, global variables can be an array, can also be a single variable,

Selfid:=WebBrowser1 OleObject. Document. ParentWindow. Current_user. Uid;
Rather take current_user [' uid]

If you take a single variable:
WebBrowser1. OleObject. Document. ParentWindow. Uid

Method 2:
Can write a js function, used to create a new hidden div tags (with id value),
Use JS execution results put inside the DIV,
Then use ID take HTML way out,
WebBrowser1. OleObject. Document. GetElementByIdx_x (' span1). The innerText;

Method recommended approach 2. Because if there is no define variables and directly take throws an exception
  • Related