Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Indy run Javascript?

There is a software product called AnyChart which is great for embedding Flashed based charts in web pages. AnyCharts can also export to PNG file format. Here is an example:

<script type="text/javascript" language="javascript">
    //<![CDATA[
    var chart = new AnyChart('http://www.mysite.com/swf/AnyChart.swf');
    chart.width = 600;
    chart.height = 300;
    chart.setXMLFile('http://www.mysite.com/anychart.xml');
    chart.addEventListener("draw", function() { saveChartAsImage(chart); });
    chart.write("content-box");
    //]]>
</script>

My ultimate goal is to make a automated service to export the AnyChart charts to PNG format. So I made a service with Indy which calls pages containing the AnyChart javascript. But the problem seems to be that Indy cannot execute the javascript.

Is there a way to enable Indy to execute javascript?

like image 393
M Schenkel Avatar asked Feb 12 '10 05:02

M Schenkel


3 Answers

No, Indy does not execute Javascript. You may have also noticed that it doesn't parse or display HTML, and it doesn't run Flash, either. Indy does network protocols.

You could import the Microsoft Script Control ActiveX object and have that run your Javascript. If you need details on that, post a new question.

like image 125
Rob Kennedy Avatar answered Oct 23 '22 21:10

Rob Kennedy


You don't have to use Indy for this. If you want you can use TWebBrowser. IHTMLWindow2 interface has execScript function. So may be you can :

var
  Doc : IHTMLDocument2;
  Win : IHTMLWindow2;
  aBrowser : TWebBrowser; 
//...
begin
  //...
  Doc := aBrowser.Document as IHTMLDocument2;
  Win := Doc.parentWindow;
  Win.execScript('alert(SomeMessage);', 'JavaScript');
end;
like image 41
SimaWB Avatar answered Oct 23 '22 23:10

SimaWB


Did you try vcl FOR THE web (aka Intraweb atozed) ? There is a teechart version wich is quite useful, you can also execute "external" javascript code within any of the TiwForms of your web app (the exact same code you are using now).

Post a new question if you need to and I'll be glad to help.

like image 35
M0-3E Avatar answered Oct 23 '22 23:10

M0-3E