Jump to content

Recommended Posts

Posted

Hi to all.

 

How can I get into a Delphi variable the result of a JavaScript function like getTimezoneOffset() ?

 

I can successfully execute the following and get the result on caption of UniLabel1

 UniSession.AddJS(
   'var d = new Date(); ' +
   'var _offset = (d.getTimezoneOffset() / 60 ) * -1; ' +
   'TestForm.UniLabel1.setText(_offset); '
   );

 

 

Regards.

  • Administrators
Posted

It can be done using an Ajax request:

 

  UniSession.AddJS(
'var d = new Date(); ' +
'var _offset = (d.getTimezoneOffset() / 60 ) * -1; ' +
'ajaxRequest(MainForm.form, "mycall", ["ofs="+_offset]); '
);

 

 

procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
 Params: TStrings);
begin
 if EventName='mycall' then
 begin
UniLabel1.Caption:=Params.Values['ofs'];
 end;
end;

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...