Detecting Xojo from a webpage

I have php site that will sometimes be run from a specific Xojo App HTML control, and sometimes from a general browser. Is there a php/javascript-way to know if a site is being displayed within a Xojo desktop app?

BTW, I have worked with the php ‘getBrowser();’ and it returns an unknown when loaded in a Xojo App, whereas it states the browser type otherwise.

I found that you can change the User Agent of the HTMLViewer manually in Xojo. That would work for me, however, it have a note that this is OS X only. No similar function on Windows?

If both the browserapp and the php are yours, set HTMLViewer.UserAgent to a custom value that your PHP will get and recognize through Get_Brower. PHP: get_browser - Manual

Set the User Agent : http://documentation.xojo.com/index.php/HTMLViewer.UserAgent

@Michel Bujardet Thank you for the reply. I had found the UserAgent, and got excited. Then I saw that it is only available for MAC OS deployment? Then I got sad again.

Once again, all depends if you master the client app or not. If you do, then you can add code to the HTMLViewer to signal your PHP. For instance, you could add a parameter to the URL. Something like http://www.mysite.com/index.php?bro=xo. Easy to get from php.

In MBS Plugins I think we have method to set user agent. So you could detect your own app showing your website in a htmlviewer .

I believe MBS has a way to set UserAgent in Windows apps.

@Michel Bujardet Yep, I have access to both. I figured I could pass the log in into the php with URL variables. I just wanted see if making the website intelligent on this aspect without depending that type of call from Xojo.

@Christian Schmitz Thanks for the heads up on MBS. I have to admit that I’m disappointed at the amount of functionality that doesn’t come from Xojo and needs to be fulfilled by 3rd Party. To take the time to have the ability to do one thing on OS X, but not in Windows is not good. Especially if a small 3rd party can develop a workaround.

@Bob Keeney Hey Bob! Good to see you. :wink: I’ll drop a line to Robert about this. XD

I’d try the User agent string anyways
I suspect the docs are wrong on this one

Interesting. I’ll check it out on my Win-box.

I just did
I just made a tiny app with an htmlviewer and a button
The button just had an action event with

htmlviewer1.useragent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.76.4 (KHTML, like Gecko) Version/6.1.4 Safari/537.76.4" htmlviewer1.loadurl("https://www.whatismybrowser.com/what-is-my-user-agent")

And that seems to report whatever I set
Others must be doing something else as they report other things
So I’m not 100% sure it is or is not working

sad face

I see what workaround I can locate. The URL parameters is possible, but would be nice to have this functionality.

I’d still try it on your side as I have had some places echo back what I set & some not
Not sure why

[quote=114019:@Todd Fletcher]sad face

Apparently, using Native won’t do : latest versions of IE don’t store the user agent string in the Registry anymore.

I tried what works for Chrome with a Xojo app with Webkit browser : chrome.exe --user-agent="mystring" but no luck either.

There is apparently no way to do it through JavaScript either on the client side.

Your options seem to be MBS or URL parameter…

[quote=114016:@Norman Palardy]I’d try the User agent string anyways
I suspect the docs are wrong on this one[/quote]

You can only set UserAgent on Mac OS X. It is ignored for webkit in Windows.

MBS has a function for native (Internet Explorer) htmlviewer in Windows but, as far as I can tell, nothing for WebKit.

On Windows 7 in Xojo 2014r2 I just made a tiny app with an htmlviewer and a button
The button just had an action event with

htmlviewer1.useragent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.76.4 (KHTML, like Gecko) Version/6.1.4 Safari/537.76.4"
htmlviewer1.loadurl("https://www.whatismybrowser.com/what-is-my-user-agent")

And that seems to report whatever I set
Others must be doing something else as they report other things
So I’m not 100% sure it is or is not working
And that was using the native renderer for the HTMLViewer

If I use the Native Renderer in Windows it reports what I put in for the User Agent. If I use Webkit it ignores it.

Mac is no problem.

[quote=114212:@Norman Palardy]On Windows 7 in Xojo 2014r2 I just made a tiny app with an htmlviewer and a button
The button just had an action event with

htmlviewer1.useragent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.76.4 (KHTML, like Gecko) Version/6.1.4 Safari/537.76.4"
htmlviewer1.loadurl("https://www.whatismybrowser.com/what-is-my-user-agent")

And that seems to report whatever I set
Others must be doing something else as they report other things
So I’m not 100% sure it is or is not working
And that was using the native renderer for the HTMLViewer[/quote]

Just tried with Windows 8.1 and it works fine as well. So the LR is partly in error : it works for Windows native, and not just OS X.

[quote=114215:@Bob Keeney]If I use the Native Renderer in Windows it reports what I put in for the User Agent. If I use Webkit it ignores it.
[/quote]
Actually that I can believe
That looks like a bug