05-09-2022, 05:05 PM
Here's what I want to do:
When my application starts and whenever the end user resizes the browser window, I want it to center horizontally in the browser window (if the visible window is wider than my region) or left-justify (if the window is narrower than my region). I tried adding Div [margin: auto;] to my css but that did nothing, so I found a centering example in the IntraWeb Downloads page.
Unfortunately, the example uses Parent.Width, which is effectively WebApplication.FormWidth, which is not the correct number. For example, if my browser width is 1920 pixels and my region is 1000 pixels wide, it correctly reports a width of 1920 and centers at left position 460. But if the user then resizes the window to 800 pixels wide, FormWidth is reported as 1460 (the previous left + width of my region) instead of 800, and so instead of setting left = 0, it erroneously sets left = 230.
I've looked online and have found live examples that display the correct visible browser dimensions whenever the screen resizes - one such example is here at https://usefulangle.com/post/190/javascr...dth-height
It appears that the solution is very simple in Javascript - all I need is window.Innerwidth. My difficulty is that (a) I don't know Javascript, and (b) I don't know how to call Javascript from IntraWeb and get back a value, and that's my question: Can anyone please help me and show me how to make a Javascript call from Delphi + IntraWeb and then either (a) position my region via Javascript or (b) pass back the value of window.Innerwidth to Delphi so I can position things via Delphi code.
Many, many thanks in advance for any help you can provide - I have a feeling this is should be a really simple thing, but I simply don't know how to make the necessary call.
Kind regards,
George
When my application starts and whenever the end user resizes the browser window, I want it to center horizontally in the browser window (if the visible window is wider than my region) or left-justify (if the window is narrower than my region). I tried adding Div [margin: auto;] to my css but that did nothing, so I found a centering example in the IntraWeb Downloads page.
Unfortunately, the example uses Parent.Width, which is effectively WebApplication.FormWidth, which is not the correct number. For example, if my browser width is 1920 pixels and my region is 1000 pixels wide, it correctly reports a width of 1920 and centers at left position 460. But if the user then resizes the window to 800 pixels wide, FormWidth is reported as 1460 (the previous left + width of my region) instead of 800, and so instead of setting left = 0, it erroneously sets left = 230.
I've looked online and have found live examples that display the correct visible browser dimensions whenever the screen resizes - one such example is here at https://usefulangle.com/post/190/javascr...dth-height
It appears that the solution is very simple in Javascript - all I need is window.Innerwidth. My difficulty is that (a) I don't know Javascript, and (b) I don't know how to call Javascript from IntraWeb and get back a value, and that's my question: Can anyone please help me and show me how to make a Javascript call from Delphi + IntraWeb and then either (a) position my region via Javascript or (b) pass back the value of window.Innerwidth to Delphi so I can position things via Delphi code.
Many, many thanks in advance for any help you can provide - I have a feeling this is should be a really simple thing, but I simply don't know how to make the necessary call.
Kind regards,
George