Call JavaScript from Pascal

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>

You can put JavaScript directly in your project via an ASM block:


asm
  // your JavaScript code here
end;

I'm trying to get a returned value from a JavaScript function and place it in a Pascal variable. 

You can just use something like:

var
  s: string;
begin
  asm
     s = myJavaScriptProc();
  end;
end;