Can Indy run Javascript?

不想你离开。 提交于 2020-01-14 09:14:05

问题


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?


回答1:


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.




回答2:


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;



回答3:


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.



来源:https://stackoverflow.com/questions/2249880/can-indy-run-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!