How to access javascript variable via MSHTML in Dephi?



Hi there,
My webpage is written in HTML including a very simple javascript
function in which a variable myvar is defined. Now, I am using
Delphi's TWebbrowser to access the page and trying to access the
change of the variable with MSHTML interface. Here is my code

var
Doc: IHTMLDocument2;
HTMLWindow: IHTMLWindow2;
JSFn: string;
begin
Doc := AutoWebBrowser2.Document as IHTMLDocument2;
if not Assigned(Doc) then Exit;
HTMLWindow := Doc.parentWindow;

if not Assigned(HTMLWindow) then Exit;
try
JSFn := 'if (myvar==3) {alert("Done");}';
HTMLWindow.execScript(JSFn, 'JavaScript'); // this run without any
problem
except
showmessage('error');
end;
end;

I can even change the script to modify the variable like
JSFn := 'myvar=-2;';

However, what my need is to get the value of myvar and return it to
Delphi. I try to collect all elements of IHTMLDocument2 but seems not
found any function or property related to the variable defined in
javascript. How can I get the value return by a javascript function?

Thanks
.



Relevant Pages

  • Re: drop down selection box
    ... What about users without javascript ... plain links will mess up design/layout especially as the film titles ... ahh i seem to remember seeing that on my google travels but couldnt ...
    (alt.html)
  • Re: drop down selection box
    ... What about users without javascript ... plain links will mess up design/layout especially as the film titles ... Using a redirect script makes you need only one server side script instead of making all your pages to server side scripts. ...
    (alt.html)
  • Re: error in IE with CDATA inside javascript script
    ... I've spent a lot of time on this and would really appreciate ... And what happens after the exit? ... In Firefox, it works as is. ... The javascript is at the bottom of the page but before the footer. ...
    (comp.lang.javascript)
  • Re: JavaScript pie / ie
    ... I think that what you probably want to do is build your own browser that has ... At that point, yes, you can't exit ... Our application uses JavaScript in three areas as follows; ... If the OS is built with IE6, this did interpret JavaScript but makes ...
    (microsoft.public.windowsce.platbuilder)
  • TWebbrowser Javascript-Kontrolle
    ... Also ich habe eine Applikation mit der Componente TWebbrowser. ... Nun wird auch Javascript mit in dem HTML-Code verwendet. ... (htmlDoc ist IHTMLDocument2 document der TBrowserinstance) ...
    (de.comp.lang.delphi.misc)