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

New Developer
Posts: 6
Registered: ‎05-07-2009
My Device: Not Specified

BrowserField w/ javascript and CSS



I'm trying to change the display CSS property on a div inside a BrowserField object using javascript.  From what I can tell, the javascript I am using should be supported for the browser I am using, but I am unable to read, let alone write CSS properties on my HTML Elements.


This is my html page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"><html> <head> <script type="javascript/text"> function goToArticle() { window.alert(document.getElementById('article_list')); window.alert(document.getElementById('article_list').style); window.alert(document.getElementById('article_list').style.display); window.alert(document.getElementById('article')); window.alert(document.getElementById('article').style); window.alert(document.getElementById('article').style.display); document.getElementById('article_list').style.display = 'none'; document.getElementById('article').style.display = 'block'; } </script></head><body> <div id="article_list" style="display: block;"> <b>This is the article list page</b><br/> <a href="javascript&colon;goToArticle(); return false;">goToArticle </a><br/> </div> <div id="article" style="display: none;"> This is the article.<br/> </div> </body></html>

I'm using an embedded browser in a java app using the BrowserField object based on the SDK examples.  I have that part full working and am able to view the page.  Additionally, some of my javascript works, just not all.  My current target is OS 4.6+ and I am running on a 4.6.1 simulator.


The document.getElementById call returns an HtmlElement as expected.  The call to the style on the HtmlElement returns an Object (curiously, this says Object and not CSSStyleDeclaration as I would have excepted) (javascript ref: http://docs.blackberry.com/en/developers/deliverables/8861/CSSStyleDeclaration_568452_11.jsp).  The next call to the display property returns undefined.  The setting of the css display property on the two elements also has no effect. 


Is it even possible to change CSS properties after a page has rendered based on the user's action (in this case following a link).  If so, how do I go about doing it or is this a limitation of the BrowserField embedded browser feature.



Duane Homick | Homick Enterprises 

e: duane@homick.com | www.homick.com 




New Developer
Posts: 35
Registered: ‎12-22-2009
My Device: Bold 9700

Re: BrowserField w/ javascript and CSS

Hi Duane... have you solved this issue? I had some troubles with the CSS properties on the Simulators (using Embedded Browser in my app) but once deployed to a real device it worked fine (Storm 9550). Seemed to me that was a simulator issue rather than the real Browser's CSS capabilities.

Rodrigo Bravo