Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Start javascript on opening page
#1
Hi,

How can a javascript function (from a file) automatically be started when opening a webpage?

I have already added the Javascript filename to Contentfiles and executed a function but got no result.

Greetz
Reply
#2
Have you checked the browser console window for errors (F12 - dev tools - Console tab)?

also, have you checked the network tab (in the same dev tools area) to see if your JavaScript file loaded correctly from server?

About your question, you can execute it like this (This is one of the ways. Actually there are several different ways to accomplish the same thing):

procedure TIWForm1.OnRender(Sender: TObject);
var
JS: string;
begin
JS := 'yourjsfunction("somestringparameter", 2, 20, "another string parameter");';
AddToInitProc(JS);
end;
Reply
#3
The Javascript has loaded correctly from the server.

I didn't had the OnRender call so that is probably the cause.

Thanks for the info.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)