views:

289

answers:

3

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?

+6  A: 

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.

Rob Kennedy
+3  A: 

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;
SimaWB
Thank you. I will have to hunt down the IHTMLWindow2 interface.
M Schenkel
+1  A: 

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.