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

Web and WebWorks Development

Posts: 18
Registered: ‎03-22-2013
My Device: Playbook
My Carrier: N/A

Open a link on Playbook Browser.

Greetings, I am developing an app for BlackBerry Plabyook with rss news reader. I've been able to read the data and display the news list with its own title and description.
The link to go to the full story is in the title, that is, if you click on the title redirects to the full story in an external source.
When I test the app on the emulator Ripple, this works well, by clicking on the title of a news item from the list, it opens a new window in Chrome with the corresponding link of the news.
The problem is on the Playbook, as similarly shown correctly news list with its own title and description, but selecting the title to open the new link, it does nothing.
In the JavaScript file I have the following two lines of code:

link.setAttribute('href', entries[i].link);            

If I leave only the first line of code, then the app does work and open the link. The problem is that it opens that link within the app and that's not the idea.


So I guess instead of the second line of code, I should add an instruction for the link to open in a new window of the browser app.

This is the JavaScript code I'm using to read the feed of news:

function myGetElementsByClassName(selector) {
    if ( document.getElementsByClassName ) {
        return document.getElementsByClassName(selector);

    var returnList = new Array();
    var nodes = document.getElementsByTagName('div');
    var max = nodes.length;
    for ( var i = 0; i < max; i++ ) {
        if ( nodes[i].className == selector ) {
            returnList[returnList.length] = nodes[i];
    return returnList;

var rssReader = {
    containers : null,

    // initialization function
    init : function(selector) {
        containers = myGetElementsByClassName(selector);
            // getting necessary variables
            var rssUrl = containers[i].getAttribute('rss_url');
            var num = containers[i].getAttribute('rss_num');
            var id = containers[i].getAttribute('id');

            // creating temp scripts which will help us to transform XML (RSS) to JSON
            var url = encodeURIComponent(rssUrl);
            var googUrl = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num='+num+'&q='+url+'&callback=rssReader.p...

            var script = document.createElement('script');

    // parsing of results by google
    parse : function(context, data) {
        var container = document.getElementById(context);
        container.innerHTML = '';

        // creating list of elements
        var mainList = document.createElement('ul');

        // also creating its childs (subitems)
        var entries = data.feed.entries;
        for (var i=0; i<entries.length; i++) {
            var listItem = document.createElement('li');
            var title = entries[i].title;
            var contentSnippet = entries[i].contentSnippet;
            var contentSnippetText = document.createTextNode(contentSnippet);

            var link = document.createElement('a');
            link.setAttribute('href', entries[i].link);

            var text = document.createTextNode(title);

            // add link to list item

            var desc = document.createElement('p');

            // add description to list item

            // adding list item to main list

window.onload = function() {

And here is the HTML:

<!DOCTYPE html>
    <meta id="viewport" name="viewport" content="user-scalable=no,
    width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0;" />
    <link href="style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="scripts/news.js">

    <div id="content">
        <div class="news">
            <div class="post_results" id="post_results1" rss_num="20" rss_url="http://allafrica.com/tools/headlines/rdf/soccer/headlines.rdf">
                <div class="loading_rss">
                    <center><img alt="Loading..." src="images/loader.gif" /></center>
            <div style="clear:both;"></div>


I really appreciate any ideas or suggestions you may have.




Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Open a link on Playbook Browser.

Unless I misunderstood, would the Browser invocation API be of use here?




Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.