Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dinamically load Javascript
#1
Hi All,

This question probably will make smile the experts, but I would need to access javascript functions imported from another site at session creation to interact with it.
They told me that I shoud use this <script src="http://www.theirsite.com:85/js/siteIntegration.js" type="text/javascript"></script>

This is the first time I am facing such a request, but really don't know the howto.

Thanks for everyone support

/Claudio
Reply
#2
Hi Claudio. You can load this JS OnCreate your form.

Code:
procedure TIWForm1.IWAppFormCreate(Sender: TObject);
begin
  Self.JavaScript := '<script src="http://www.theirsite.com:85/js/siteIntegration.js"></script>';
end;
Reply
#3
(11-18-2018, 07:41 AM)duffo64 Wrote: Hi All,

This question probably will make smile the experts, but I would need to access javascript functions imported from another site at session creation to interact with it.
They told me that I shoud use this <script src="http://www.theirsite.com:85/js/siteIntegration.js" type="text/javascript"></script>

This is the first time I am facing such a request, but really don't know the howto.

Thanks for everyone support

/Claudio

Why do you need to do it at Session creation? You can just put that script line in your ServerController.HTMLHeaders. By so doing you all of your sessions will be able to use it.

And get rid of this:

type="text/javascript"

It is not needed in HTML5 -- it is assumed that you are using JavaScript as your script language.
Reply
#4
Thank you guys,

In the meantime I seen that I can load the JS even calling ContentFiles->Add("http:// etc etc") in ServerController constructor.
But now I would have another question: since I can load the JS in both ContentFiles or HTMLHeaders, is there any functional difference between the two ?

/Claudio
Reply
#5
I have got my target with this. Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)