OS Detection - How to use it

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.


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

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


Code: Select all

to have my docs selectively render content that specifically targets each of these platforms (iOS and Android)?



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


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.


Post Reply