Jump to content

Passing information to the browser


david_navigator

Recommended Posts

I'm evaluating uniGUI at the moment and so far I'm very impressed. Couple of questions, hope they're not FAQ's, couldn't find answers in the forums.

1. My app uses an embedded browser which pulls a web page from a uniGUI server. I'd like to set an http Server header so that the embedded browser can check that it's looking at my server. Am I correct in thinking that this is done through the  UniServerModule.Title property and that it requires the registered version to change this ?

 

2. In my app, I'd like to detect when uniGUI has terminated. In the web browser this is displayed as the following;
Web session terminated.
Restart application

but looking at the source in a browser I just see the script that presumably outputs this.

What is the best way for the embedded client browser to detect that the web session has terminated ?

 

David

Link to comment
Share on other sites

I'm using FMX.WebBrowser.TWebBrowser.

Basically I want to present my users with an app that they can download from the Android Playstore or Apple store. So I've built a delphi FMX app, which is little more than an embedded browser that points to the uniGUI server.
This way they have an icon on their device, which when they click loads up the app which displays the uniGUI mobile page within the embedded web browser. (there's a bit more too it as the uniGUI app actually runs on their network so there is a config/connection (FMX controls) screen first).

All this works well, but when they click on the "power button" in the uniGUI app, they get the message 
Web session terminated.
Restart application. 

I want to detect this message and hide the browser and reshow my fmx connect screen. If the terminated message was just plain HTML then I could use the TwebBrowser methods to parse the HTML for the string and act on that, but because the page is generated from javascript, I have nothing to detect.

So I'm just looking for something that the client browser can pickup on to realise that the session has ended - maybe a different http header field or even the title of the web page.

For some reason I can't embed images - so screen shot one shows project as icon on desktop, screen shot 2 shows fmx config screen and screenshot 3 shows embedded browser displayed after user has clicked on connect button.

screenshot 1

 

screenshot 2

 

screenshot 3


 

Link to comment
Share on other sites

I GerhardV, thanks, but it wasn't. However I've now discovered that the FMX browser doesn't allow the developer access to the source of the webpage, so the whole concept is void.

In the end I've changed the ServrMessages.TerminateTemplate to

 

<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=http://0.0.0.0">
<script type="text/javascript">
 window.location.href = "http://0.0.0.0"
</script>
 <title>Page Redirection</title>
</head>
                                                            

<body bgcolor="#dfe8f6">
<p style="text-align:center;color:#0000A0">[###message###]</p>
<p style="text-align:center;color:#A05050"><a href="[###url###]">Restart application</a></p>
</body>
</html>

which hopefully will automatically try and redirect the browser to illegal address 0.0.0.0 - this generates an error, which I can trap in the FMX.Webbrowser and use to hide the WebBrowser control and show my connection controls.

Testing all seems to work.

This gives me a PhoneGap kind of solution where the user thinks that they're running a native app, but really it's a web app.

 

[don't think I need both the javascript and the meta refresh though]

Link to comment
Share on other sites

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...