whacharachai Posted December 11, 2019 Share Posted December 11, 2019 Hi, I have uniURLFrame in my from and set it's URL to a web page. source code of that page contain a jacascript function let say function F1 to do something on the page. I would like to know how to call that javascript function from Delphi for example onclick of uniButton on a form. I have search Google world wide and this forum but can not find the answer, Please Help, Thank you Whcaharachai Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 11, 2019 Share Posted December 11, 2019 36 minutes ago, whacharachai said: I have uniURLFrame in my from and set it's URL to a web page. Hi, Are you opening a link or html file? If the link, is the link on the same domain? Quote Link to comment Share on other sites More sharing options...
whacharachai Posted December 11, 2019 Author Share Posted December 11, 2019 HI, I test my program and linked page in my localhost (127.0.0.1 Apache on Windows) Both Program (.dll) and Page are in the root of localhost. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 11, 2019 Share Posted December 11, 2019 39 minutes ago, whacharachai said: I test my program and linked page in my localhost (127.0.0.1 Apache on Windows) Both Program (.dll) and Page are in the root of localhost. Can you try this? procedure TMainForm.UniButton1Click(Sender: TObject); begin UniURLFrame1.JSInterface.JSCode(#1'.iframe.contentWindow.yourFunction();'); end; Quote Link to comment Share on other sites More sharing options...
whacharachai Posted December 12, 2019 Author Share Posted December 12, 2019 15 hours ago, Sherzod said: Can you try this? procedure TMainForm.UniButton1Click(Sender: TObject); begin UniURLFrame1.JSInterface.JSCode(#1'.iframe.contentWindow.yourFunction();'); end; Thank you very much, the code work fine. I wonder where can I find the document or example of the JSInterface like this, so I can study them myself, thank you. Quote Link to comment Share on other sites More sharing options...
55143681 Posted February 7, 2020 Share Posted February 7, 2020 On 12/12/2019 at 10:11 AM, whacharachai said: Thank you very much, the code work fine. I wonder where can I find the document or example of the JSInterface like this, so I can study them myself, thank you. what does the parameters mean? UniURLFrame1.JSInterface.JSCode(#1'.iframe.contentWindow.yourFunction();'); 1‘’ ?? iframe ?? contentWindow?? Quote Link to comment Share on other sites More sharing options...
GerhardV Posted March 31, 2021 Share Posted March 31, 2021 On 12/11/2019 at 12:09 PM, Sherzod said: Can you try this? procedure TMainForm.UniButton1Click(Sender: TObject); begin UniURLFrame1.JSInterface.JSCode(#1'.iframe.contentWindow.yourFunction();'); end; @Sherzod, can you do the same for a UniHTMLFrame? When I do this: UniHTMLFrame1.JSInterface.JSCode(#1'.iframe.contentWindow.nextStep();'); I get the following error: Quote Link to comment Share on other sites More sharing options...
GerhardV Posted March 31, 2021 Share Posted March 31, 2021 Never mind, I figured it out, one can call the function directly for a UniHTMLFrame since it isn't in a iFrame. This worked: UniHTMLFrame1.JSInterface.JSCode('nextStep();'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.