Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
zahirw
Posts: 134
Registered: ‎04-15-2012
My Device: Bold 9900
My Carrier: Vodafone
Accepted Solution

OS detection & serving

I want to write a javascript code that detects the os & serves css & js files based on it. Ex.

//detect os
//if os - 5
//serve os5framework.js
//serve os5dbconn.js
//if resolution < 320, serve os5-320.css
//if resolution > 320 but < 480, serve os5-480.css
//if resolution >= 640, serve os5-640.css

How can I detect the os & serve files based on this information?
Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: OS detection & serving

The first option is to enable access to one of your Java objects (or method) from the JavaScript.

 Check out this link:

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/browser/field2/BrowserField.ht...

 

The second option, and I haven't checked it out yet, is to try and use the WebWorks properties.

Check out this link:

https://bdsc.webapps.blackberry.com/html5/apis/blackberry.system.html#.softwareVersion

 

Hope that helps,

 

E.

 

Please use plain text.
Trusted Contributor
zahirw
Posts: 134
Registered: ‎04-15-2012
My Device: Bold 9900
My Carrier: Vodafone

Re: OS detection & serving

Awesome

Any idea how to accurately check the. Os using softwareVersion?
Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: OS detection & serving

Not sure I understand your question.

 

softwareVersion is the accurate number of the OS version.

 

Convert the two first digits into a number and use it to compare with your predefined values.

Please use plain text.
Trusted Contributor
zahirw
Posts: 134
Registered: ‎04-15-2012
My Device: Bold 9900
My Carrier: Vodafone

Re: OS detection & serving

Exactly, what syntax would I need to use?

&lt;Script&gt;
...
&lt;/script&gt;
Please use plain text.