steve589 Posted January 14, 2018 Share Posted January 14, 2018 Hi, I cannot figure out how to fire the OnAjaxEvent from JS-code within the loaded page. ajaxRequest can be called with "parent.ajaxRequest", but I cannot determine the first parameter "sender" I tried: - parent.ajaxRequest(this, "ClickEvent", [ "param0=a", "param1=b" ]); - parent.ajaxRequest(O3C, "ClickEvent", [ "param0=a", "param1=b" ]); // where "O3C" is the JS-name of the UniURLFrame (added via code on startup) - tried to get a reference to the UniURLFrame-control with: - var x = parent.getElementById("O3C"); // x is null - var x = parent.getElementById("O3C_id"); // x is null nothing works. Can anybody help please? best regards steve Link to comment Share on other sites More sharing options...
Sherzod Posted January 14, 2018 Share Posted January 14, 2018 Hi, Can you make a simple testcase indicating where the problem is ?! Link to comment Share on other sites More sharing options...
steve589 Posted January 14, 2018 Author Share Posted January 14, 2018 in MainForm there is only one UniURLFrame, then: procedure TMainForm.UniFormCreate(Sender: TObject); begin UniURLFrame1.HTML.Text := '<script type="text/javascript">' + ' document.addEventListener("click", function(e) { ' + ' parent.ajaxRequest(' + UniURLFrame1.JSName + ', "ClickEvent", [ "param0=a", "param1=b" ]);' + ' })' + '</script>' + '<br>' + 'click here' + '<br>'; end; // this is never called: procedure TMainForm.UniURLFrame1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin ShowMessage(Params.Values['param0'] + ' - ' + Params.Values['param1']); end; Link to comment Share on other sites More sharing options...
Sherzod Posted January 14, 2018 Share Posted January 14, 2018 Sorry, maybe I do not understand the issue completely, but try this: UniURLFrame1.HTML.Text := '<script type="text/javascript">' + ' document.addEventListener("click", function(e) { ' + ' parent.ajaxRequest(parent.' + UniURLFrame1.JSName + ', "ClickEvent", [ "param0=a", "param1=b" ]);' + ' })' + '</script>' + '<br>' + 'click here' + '<br>'; Link to comment Share on other sites More sharing options...
steve589 Posted January 14, 2018 Author Share Posted January 14, 2018 Yes, this works! I thought I had tried this version, but obviously I did not... Thanks a lot! steve Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now