Hello!
I try, I torture TWebBrowser so that he gives me an innerText at the link when I click.
Naryl is the only option that combines JavaScript, which changes the status text, and then event:onStatusTextChange gives us the actual text.
Those. I have javascript:
function statusChange(text) { window.status = text; } In the program it looks like:
procedure TMain.webBrowserStatusTextChange(Sender: TObject; const Text: WideString); var t: String; begin if pos('CMD:', Text) > 0 then begin t := Text; delete(t, 1, 4); reMessage.Text := t; end; end; And here is the link itself:
<a href="#" onclick="javascript:statusChange(''CMD:'+Text+'''); return false;">Текст</a> But it is impossible to do this, as the empty string is constantly returned or about:blank# . What am I doing wrong? Is it possible to do this in a different way?
UPD
The link is taken out of the program context, so the number of quotes seems strange to you.
Link := '<a href="#" onclick="javascript:statusChange(''CMD:'+Text+'''); return false;">Текст</a>' Double quote in Delphi - replaces character escaping. And for the same reason (my mistake in the question) you did not understand what Text for it is a program variable, not a script. In fact, after the link will be:
<a href="#" onclick="javascript:statusChange('CMD:Текст'); return false;">Текст</a> Those. as you wrote, you can replace innerText . But this is not the problem, it works great, but the statuses returned via the TWebBrowser event always return the text when pressed: about:blank# .
UPD2
procedure TMain.webBrowserBeforeNavigate2(Sender: TObject; const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool); var p: integer; begin p := pos('CMD:', URL); if p > 0 then ShowMessage(copy(URL, p+4, Length(URL)-p-3)); end; procedure TMain.Button1Click(Sender: TObject); begin WebBrowser.Navigate('http://sh4dow.jino.ru/test.html'); end; At the exit of your page with the program and a single pop-up message.
blank#), the function delphiRequest was not defined. I think your solution is somewhere here) Unfortunately, I don’t know the Component. - Sh4dow