Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Detecting the browser?
Thu, Jan 24 2013 12:18 PMPermanent Link

Matthew Jones

Can the code detect the browser it is running on? I just tried my test on an iPhone,
and I'd like to be able to set the width somehow to reduce it down.

Actually, I'd also like to know if the javascript code can adjust the height and
width of the browser it is hosted in? I presume not, but am pondering doing custom
browsers which look at the html and read some invisible div to get info on the size
it should be. Is this likely to be possible? A simple invisible label would do I
think.

/Matthew Jones/
Thu, Jan 24 2013 12:42 PMPermanent Link

Matthew Jones

Seems the answer to both is yes.

label1.caption := window.navigator.platform + window.navigator.userAgent;

And
Window.resizeTo(500, 500);

/Matthew Jones/
Fri, Jan 25 2013 5:49 AMPermanent Link

Claudia Borsel

If the primary reason to detect the browser is to detect the screen size of the device to fit the form accordingly, those 3 properties get some (mixed) results:

label5.caption :=
'inner: ' + inttostr(window.innerWidth) + 'x' + inttostr(window.innerHeight) + #13+#10
+'outer: ' + inttostr(window.outerWidth) + 'x' + inttostr(window.outerHeight) +#13+#10
+'screen: ' + inttostr(window.screen.width) + 'x' + inttostr(window.screen.height);

Whereas innerWidth and outerWidth and height are not really consistent across the various platforms, the screen.width and height at least seem to be the true screen size on all platforms, even reflecting the current orientation (portrait & landscape).
Fri, Jan 25 2013 6:48 AMPermanent Link

Matthew Jones

Oddly, in my case it is to make the containing browser fit the form, not the other
way round. Not in this case anyway, my other post was about getting the iPhone to
look right.

My web app will be a little utility, and would be best in a little window on its
own.

/Matthew Jones/
Fri, Jan 25 2013 11:14 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Actually, I'd also like to know if the javascript code can adjust the
height and width of the browser it is hosted in? >>

Not that I'm aware of, no.  On a desktop you can start new browser windows
and control *their* size, but that's about it.

<< I presume not, but am pondering doing custom browsers which look at the
html and read some invisible div to get info on the size it should be. Is
this likely to be possible? A simple invisible label would do I think. >>

Under which platform(s) ?

Tim Young
Elevate Software
www.elevatesoft.com


Mon, Jan 28 2013 4:58 AMPermanent Link

Matthew Jones

> Under which platform(s) ?

I'm just thinking of a Delphi application that creates a form, embeds a browser,
and opens my web page. It can then monitor the content for the hidden text, and
take appropriate actions.

/Matthew Jones/
Mon, Jan 28 2013 3:45 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< I'm just thinking of a Delphi application that creates a form, embeds a
browser, and opens my web page. It can then monitor the content for the
hidden text, and take appropriate actions.  >>

Sure, that's not a problem.  I was thinking that you wanted to do something
on iOS.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Jan 29 2013 6:43 AMPermanent Link

Matthew Jones

On iOS, I just want the form to fit the screen nicely, and not need to be zooming.
Sort of the opposite way around. I would expect to treat it differently - probably
a different application. Indeed, I guess I'd want to have the main app send the
browser to custom apps (sorry, pages with EWB code) according to capabilities.

/Matthew Jones/
Tue, Jan 29 2013 7:53 AMPermanent Link

Claudia Borsel

To let the form fit the browser nicely I got the attached code to work.
(The event handler code for resize is taken from another post in this forum.)

It works in all browsers, including desktop (resizeable) and mobile, except IE9.0 and therefore EWB-IDE. Wink


The form always fits the visible area.



Attachments: formsizetest_standard.zip
Image