Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Call JavaScript from Pascal

 Post Reply Post Reply
Author
Sanderson Howard View Drop Down
New Member
New Member
Avatar

Joined: 13 Sep 2011
Posts: 10
Post Options Post Options   Quote Sanderson Howard Quote  Post ReplyReply Direct Link To This Post Topic: Call JavaScript from Pascal
    Posted: 10 Jan 2019 at 12:10am
How do I call a JavaScript function from Pascal? I would like to use window.InnerWidth to decide on a form layout for the device the user is running on.

For example, screen resolution detection with Javascript
  You can get the outer window size with window.outerWidth and window.outerHeight.
  You can get the inner window size with window.innerWidth and window.innerHeight.
  With IE you can get it with document.body.clientWidth and document.body.clientHeight.
  You can get the screen window position with window.screenLeft and window.screenTop.
  For example:
    <script>
    alert(window.outerWidth+' x '+window.outerHeight);
    </script>
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8587
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jan 2019 at 8:35am
You can put JavaScript directly in your project via an ASM block:

asm
  // your JavaScript code here
end;
Back to Top
Sanderson Howard View Drop Down
New Member
New Member
Avatar

Joined: 13 Sep 2011
Posts: 10
Post Options Post Options   Quote Sanderson Howard Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jan 2019 at 5:50pm
I'm trying to get a returned value from a JavaScript function and place it in a Pascal variable. 
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8587
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jan 2019 at 9:40pm
You can just use something like:

var
  s: string;
begin
  asm
     s = myJavaScriptProc();
  end;
end;
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down