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
New Developer
rickyying
Posts: 1
Registered: ‎02-06-2009
My Device: Not Specified

Javascript in BrowserField

I got this strange problem. There javascript does not work in BrowserField application.

It works when I have following code in page:
<a href="javascript&colonalert('alert');">Alert</a>

It will stop working when I have my own javascript block:
<script type="text/javascript">
  function Submit(evt)
  {
    alert(evt);
  }
</script>
<a href="javascript&colonSubmit('alert');">Alert</a>
 
I got error message in my JDE:
ThrownValue in ExecuteMethod ReferenceError: "Submit" is not defined.
Running  at line    3: Submit("setup");} }.

Both links work fine in BlackBerry browser, But not in BrowserField.

I tried it in both JDE 4.6 and 4.7. It there any settings I need to do?
 
I have enabled the javascript
_renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.JAVASCRIPT_ENABLED, true); 
Please use plain text.
Administrator
MSohm
Posts: 14,516
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Javascript in BrowserField

My first recommendation is to rename your method to something other than submit.  Also note that the browser field does not use the new browser engine introduced in BlackBerry handheld software version 4.6.0.  It uses the previous engine, therefore you should test using version 4.5.0 of the BlackBerry Browser in order to better align with the features of a browser field.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
tacchan666
Posts: 20
Registered: ‎11-12-2008
My Device: Not Specified

Re: Javascript in BrowserField


rickyying wrote:
I got this strange problem. There javascript does not work in BrowserField application.

It works when I have following code in page:
<a href="javascript&colonalert('alert');">Alert</a>
[omissis]
 
I have enabled the javascript
_renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.JAVASCRIPT_ENABLED, true); 

 

How do you do that? because my code does not works: without enabling javascript and clicking on a button that has javascript code in it, the handheld tells me it cannot execute the script, rightfully. So I enabled javascript using the very same method you used (setProperty on RenderingOptions of RenderingSession), and what I get is that the handheld does not warn me anymore about javascript, but nothing happens.

I tried a document.write() on loading the page and this works, but embedding code in a button gives no results. And even if the javascript lies into an href -- when trapping the onMenu event and manually executing the thread corresponding to the Get Link item -- nothing happens (nor an event is received on eventOccurred(), method of the RenderingSession interface). Moreover, the Event.EVENT_EXECUTING_SCRIPT event does not fire...

If this last paragraph is a little confusing, I will explain it better, just ask :smileyhappy:

 

 

Thank you all in advance.

Please use plain text.
Developer
tacchan666
Posts: 20
Registered: ‎11-12-2008
My Device: Not Specified

Re: Javascript in BrowserField

I found the solution :smileyhappy:
Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Javascript in BrowserField

You could mark the thread as solved and also share the solution will be real help for other users.

Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
tacchan666
Posts: 20
Registered: ‎11-12-2008
My Device: Not Specified

Re: Javascript in BrowserField

Oh, for what concerns my problem, I simply forgot to implement RenderingApplication.invokeRunnable()... my fault
Please use plain text.
New Developer
rodrifox
Posts: 35
Registered: ‎12-22-2009
My Device: Bold 9700

Re: Javascript in BrowserField

Hi... just in case do you know where can I find the BrowserField specs. for the SDK 5? It seems it doesn't support dynamic javascript (like the old BB Browsers). Thanks!

-------------
Rodrigo Bravo
http://www.wilkonit.com
Please use plain text.