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

Native Development

Reply
New Member
shubham26
Posts: 2
Registered: ‎07-02-2013
My Device: Z10
My Carrier: Airtel

JavaScript interaction with Code

I've two queries related to JavaScript interaction from webView to cascades blackberry code.

 

1. I need to send message to a function in the JavaScript of the page.
i.e. i need to call a JavaScript function of the page which is currently opened in webView, and send the message as function parameters.
Something similar to JavaScript interface in Android.


2. I need to receive data from a function that executes on load of the web page's JavaScript which is loaded in webView.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: JavaScript interaction with Code

Reading the documentation for WebView, especially the introductory paragraphs. You'll find this and more:

 

You can interact with JavaScript executing on the page by using postMessage() and connecting to the messageReceived() signal. JavaScript can communicate back by using the navigator.cascades.postMessage() function and storing a message handler in the navigator.cascades.onmessage property.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
New Member
shubham26
Posts: 2
Registered: ‎07-02-2013
My Device: Z10
My Carrier: Airtel

Re: JavaScript interaction with Code

Is there any generic way of doing the same thing in which i can call any function in JavaScript of the page other than this particular navigator.cascades.postMessage() function
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: JavaScript interaction with Code

Please, could you start by reading that documentation? The paragraph following the one I just quoted has your answer.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.