开发者

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 开发者_Python百科javascript. But the problem seems to be that Indy cannot execute the javascript.

Is there a way to enable Indy to execute javascript?


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.


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;


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜