Atozed Forums

Full Version: Start javascript on opening page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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.

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);
JS: string;
JS := 'yourjsfunction("somestringparameter", 2, 20, "another string parameter");';
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.