OS Detection - How to use it

gullinx
Posts: 5
Joined: Sat Dec 15, 2012 3:09 am

OS Detection - How to use it

Post by gullinx » Fri Jun 28, 2013 12:23 am

I noticed that you include a JavaScript file that contains code for getting the browser name and the operating system name from the web client (web browser) that is currently displaying the documentation that I created with oXygen.

This is the fully-qualified path name of the JavaScript file that I'm talking about:

Code: Select all

C:\Program Files\Oxygen XML Editor 15\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\oxygen-webhelp\resources\js\browserDetect.js
I was curious to see if this information was actually available, so I opened my compiled web doc set in Internet Explorer, and then I performed the following steps:
  1. I open the Developer Tools (by pressing F12),
  2. Clicked the Script tab,
  3. Selected the Watch pane,
  4. Clicked inside the Watch pane, and added the variable this.
  5. Then I clicked the little plus sign beside this, to expand it so I could see all of the property variables for the current session.
I was amazed to see the wealth of information it contained (several pages!).
The BrowserDetect object was the third item in the list.

Image

So this is great! It means my web docs "know" which web browser they're currently being displayed in, and which operation system that browser is currently running on!

Code: Select all


this.BrowserDetect.versionSearchString="Windows"
this.BrowserDetect.browser="Explorer"
this.BrowserDetect.version=10
this.BrowserDetect.OS="Windows"
So Here's My Question...

The mobile version of the web docs I'm authoring, apply to both the iPhone and to Android-based devices. If I tag my content appropriately, can I use

Code: Select all

this.BrowserDetect.OS="iOS"
and

Code: Select all

this.BrowserDetect.OS="Android"
to have my docs selectively render content that specifically targets each of these platforms (iOS and Android)?


Thanks,

Chris.

sorin_ristache
Posts: 4144
Joined: Fri Mar 28, 2003 2:12 pm

Re: OS Detection - How to use it

Post by sorin_ristache » Fri Jun 28, 2013 12:12 pm

Hi,

I think the BrowserDetect object could be used for targeting the iOS and Android platforms but first you have to complete the dataOS array in the BrowserDetect object because in the current form the list of known OSes does not include iOS and Android. The platform detection is performed in the init() function which looks for the platform in the dataOS array, so this array must include the two platforms that you want to detect.


Regards,
Sorin

Post Reply