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

Web and WebWorks Development

Reply
New Developer
Posts: 39
Registered: ‎01-10-2014
My Device: BlackBerry Q5
My Carrier: BlackBerry
Accepted Solution

Unable to parse xml.aspx in my html5 app Error"JavaScript Alert Access to http://------------------------------xml.aspx" is not allowed etc

 

 

This is my      main.js

 

 

 

 

var mstep="lang";
var mstep1="";
var mchannels = [];
var mediumURL = "http://--------------------------------------------------------xmlnew.aspx?bandwidth=Medium";
var lowURL = "http://--------------------------------------------------------------xmlnew.aspx?bandwidth=Low";
var lowURL = "http://--------------------------------------------------------------xmlnew.aspx?bandwidth

 

 

 

 

 

=High";
var finalURL = "";

$(function() {
  var pusher = new Pusher('51cb33412b3fe4182e3b');
  var channel = pusher.subscribe('test_channel');
  var notifier = new PusherNotifier(channel);
});
 function test_fn() {
        
        var channels = mchannels;    
        var markup = "";                
        for(i=0; i < channels.length; i++){        
            var ch=channels[i];            
            if(ch['language']==mstep1)    {
                markup += generateHTMLMarkup(i, channels[i]);    
            }        
        }    
        document.getElementById("accordian").innerHTML = markup;
    }

 function generateHTMLMarkup(i, channel){
    
        var str ="";
            var channelName = channel['name'];

    if (channelName.length > 18) {
STR = STR.substr(0,16) ;
}
        str +=  "<div class='ui-category-list-item-title-for-Global-Takeof'\">";        
        str +=  "<img class='img_chan'style='margin-top:10px;' src=\"" + channel['image'] + "\"  />" +
                "<a href=\"" + channel['link'] + "\">" + channel['name'].replace("Low",".") + "</a>" + "</div>";
            //    str += "<div class='ui-list-item'>"+  "<a href=\""+ channel['link']+"\">"+"</a>"+" </div>";
                str +=     "<div class='ui-list-item'>"+ +  "<a href=\""+ channel['link']+"\">"+"</a>"+" </div>";
            //    str +=" <div onclick="mwl.hide('#app_ui');mwl.show('#splash');mwl.timer('timer', 500, 1,'mwl.hide(\'#splash\');mwl.show(\'#app_ui\'); mwl.loadURL(' channel['link']')">Start video</div>";
                
        return str;

    }

 

 

 

 

var xmlDataSource = {
    
    URL: "http://-----------------------------mlnew.aspx",
    
    init: function() {            
            //URL, success callback, failure callback        
        
            this.connect(this.URL, this.responseHandler, this.failureHandler);    
    },        
    
    /**
     * Parses XML document into JS Object array
     * @param xmlDoc XML Document
     * @returns {Array} array of device objects
     */
    parseResponse: function(xmlDoc) {
                
        var chElements = xmlDoc.getElementsByTagName("channel");
            
        var channels = [];
        
        console.log(chElements.length);
        
        for(var i=0; i < chElements.length; i++){    
                
            var channel = {    };
            
            for(var j=0; j < chElements[i].childNodes.length; j++){            
                
                var node = chElements[i].childNodes[j];
                                                
                if(node.nodeType != 1){ //not an element node
                    continue;
                }

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>AppTV</title>
    <link href="s40-theme/css/s40-theme.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript" src="js/jquery-latest.pack.js"></script>
    <script language="javascript" type="text/javascript" src="s40-theme/js/screensize.js"></script>
    <script language="javascript" type="text/javascript" src="js/main.js"></script>
    <script language="javascript" type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript">
    function openWebLinkInBrowser() {
    // open web link in browser
    blackberry.invoke.invoke({
        target: "sys.browser",
        uri: "http://www.blackberry.com"
    }, onInvokeSuccess, onInvokeError);
}
  
</script>
    <script type="text/javascript" src="mwl-2.0.js">
	  var port = 153;
  var serverUrl = "http://pushapi.eval.blackberry.com";
  var appId = "50616";
  var max = 100;
  var wakeUpPage = "push.htm";
  function openBISPushListener() {
    try {
      var ops = {port : port, appId : appId, serverUrl : serverUrl, wakeUpPage : 'push.htm', maxQueueCap : max};
      blackberry.push.openBISPushListener(ops, onData, onRegister, onSimChange);
    }
    catch (err) {
      alert(err);
    }     
  } 

  function onRegister(status) {
    if (status == 0) {
      alert("success");
    }
    else if (status == 1) {
      alert("network error");
    }
    else if (status == 2) {
      alert("rejected by server");
    }
    else if (status == 3) {
      alert("invalid parameters");
    }
    else if (status == -1) {
      alert("general error");
    }
    else {
      alert("unknown status");
    }
  }
	
  function onData(data) {
    var resultDiv = document.getElementById("resultDiv");
    try {
      resultDiv.innerHTML += "<br>" + blackberry.utils.blobToString(data.payload);
      return 0; //indicate acceptance of payload for reliable push
    } 
    catch (err) {
      alert(err);
    }
  }

  function onSimChange() {
    var resultDiv = document.getElementById("resultDiv");
    resultDiv.innerHTML += "<br>" + "SIM card is changed!";
  }
	</script>
	<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
 <script src="realtime-notifications/src/lib/gritter/js/jquery.gritter.min.js"></script>
 <link href="realtime-notifications/src/lib/gritter/css/jquery.gritter.css"rel="stylesheet" type="text/css" />
  <script src="http://js.pusher.com/2.1/pusher.min.js"></script>
 <script src="realtime-notifications/src/PusherNotifier.js"></script>
  <script src="realtime-notifications/src/Node.js"></script>
<script>
$(document).ready(function() {
$(".tab_one").click(function (e) {
e.preventDefault();
$(".tab_one").addClass("selected").not(this).removeClass("selected");
});
});
</script>
</head>
<body onload="xmlDataSource.init();">
    <div class="ui-page">
        <!-- header -->
        <div class="ui-header" id='test'>
            <table class="header_table" border="0" cellspacing="0" cellpadding="0">
	          <tr>
	            <td class="header_table_td_height"><div class='ui-title'><img src="logo.png" width="200" height="60"></div>
				 <div id="back"  onclick="xmlDataSource.init();hideTab();">
    	<span class='back_btn'>Back</span>
    </div> 
				</td>
	          </tr>
			   </table>
        </div>
        <div class="ui-content" >
 		<div id="tabs" style="display:none;">
        <table>
        	<tr>
            	<td width="33%"><div onclick="LoadParser('2g');" class="tab_one selected">2G : Low</div></td>
                <td width="33%"><div onclick="LoadParser('3g');" class="tab_one">3G : MEDIUM</div></td>
                <td width="34%"><div onclick="LoadParser('wifi');" class="tab_one">WIFI : HIGH</div></td>
            </tr>
        </table>
				<!--<ul>
					<li><div onclick="bandtype='Low';test_fn('2g');" class="">2G : Low</div></li>
					<li><div onclick="bandtype='Medium';test_fn('3g');">3G : MEDIUM</div></li>
					<li><div onclick="bandtype='High';test_fn('wifi');">WIFI : HIGH</div></li>
				</ul>-->
			</div>
			
		</div><div class="ui-category-list" id="accordian" >		

			</div>	
    </div>   
    
   
</body>
</html>

 


                            
                channel[node.tagName] =  node.textContent;
            }
            
            channels.push(channel);
        }
        console.log(channels.length);
        mchannels=channels;

        return channels;    
    },
    
    /**
     * Handles the response, and displays device data in web app
     * @param xmlDoc
     */
    responseHandler: function(xmlDoc) {
        
        var channels = this.parseResponse(xmlDoc);    
        var markup = "";
        var lngrow = 0;    
        for(lng=0; lng < channels.length; lng++){        
            //FOR LANGUAGE
            
            if(lng<1){
                markup += this.generateHTMLMarkup1(lngrow, channels[lng]);    
            }else{
                var ch=channels[lng];
                var ch1=channels[lng-1];
                
                if(ch['language']==ch1['language'])    {
                    
                }else{
                    lngrow++;
                    markup += this.generateHTMLMarkup1(lngrow, channels[lng]);    
                }            
            }    
        //markup += this.generateHTMLMarkup(i, channels[i]);    
    }    

    document.getElementById("accordian").innerHTML = markup;

    },

 

 

 

 

 

Below is my config.xml

  <?xml version="1.0" encoding="UTF-8"?> <widget xmlns="http://www.w3.org/ns/widgets" 
   xmlns:rim="http://www.blackberry.com/ns/widgets"
    version="1.0.0.0" id="AppTV"> 

	   <rim:permissions>
    <rim:permit>access_shared</rim:permit>
    <rim:permit>access_location_services</rim:permit>
    <rim:permit>use_camera</rim:permit>  
  </rim:permissions>
	 <rim:loadingScreen backgroundColor="#FFFFFF"
	 backgroundImage="background.png"
     onFirstLaunch="true"
     onRemotePageLoad="true">
   <rim:transitionEffect type="fadeIn" direction="left" />
   <rim:orientation mode="auto" />
</rim:loadingScreen>
<feature id="blackberry.identity" />
<feature id="blackberry.invoke" /> 
<access uri="http://-------xml.aspx?type=lang" />
<access uri="*" subdomains="true" />
<access uri="http://blackberry.com" subdomains="true"/>
	  <icon src="AppTV.png"/>
 <content src="index.html" /> 
    </widget>

 

 

 

Below is my index.html

 

 

 

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

Re: Unable to parse xml.aspx in my html5 app Error"JavaScript Alert Access to http://------------------------------xml.aspx" is not allowed etc

The error message you describe is directly linked to not having the appropriate <access> elements whitelisting your URLs in your config.xml.

Note that if you have the following URL
http://www.mydomain.com/stuff/and/more/stuff.aspx

You want the following whitelist:
<access uri="http://mydomain.com" subdomains="true" />

You should not include the extra parameters (i.e. type=lang, etc.)

That will cover any variations of the subdomain (www, etc.) and anything following .com (i.e. extra parameters.)

Also, be sure to match HTTP and HTTPS whitelisting properly based on your URLs that you are accessing. If you are going to HTTPS URLs, you need to whitelist an HTTPS <access> element. Ditto for HTTP.

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.
New Developer
Posts: 39
Registered: ‎01-10-2014
My Device: BlackBerry Q5
My Carrier: BlackBerry

Re: Unable to parse xml.aspx in my html5 app Error"JavaScript Alert Access to http://------------------------------xml.aspx" is not allowed etc

Thank you I will try all your suggestions and update you by evening.

 

 

 

 

New Developer
Posts: 39
Registered: ‎01-10-2014
My Device: BlackBerry Q5
My Carrier: BlackBerry

Re: Unable to parse xml.aspx in my html5 app Error"JavaScript Alert Access to http://------------------------------xml.aspx" is not allowed etc

Yes your code        is working    

 

 

i.e  including    like

 

<access uri="http://mydomain.com" subdomains="true" />

 

Do you mean to say if I want to use n number of url's like

 

 

<access uri="http://ytv.com/m/symbianxmlnew.aspx" subdomains="true" />
<access uri="http://img.live.yupptv.com" subdomains="true" />
<access uri="http://edge.static.cdn.yupptv.tv" subdomains="true" />
<access uri="http://www.webmobiads.com/bmobile/iphonead.aspx" subdomains="true" />
<access uri="http://ytv.com/m/symbianxmlnew.aspx" subdomains="true" />
<access uri="http://ytv.com/m/symbianxmlnew.aspx?bandwidth=Medium" subdomains="true" />
<access uri="http://ytv.com/m/symbianxmlnew.aspx?bandwidth=Low" subdomains="true" />
<access uri="http://ytv.com/m/symbianxmlnew.aspx?bandwidth=High" subdomains="true" />
<access uri= "http://code.jquery.com/jquery-1.7.1.min.js"subdomains="true" />

 

 

 

I have to mention them all in config.xml        and there is no other alternative

 

 

Please reply ASAP

 

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

Re: Unable to parse xml.aspx in my html5 app Error"JavaScript Alert Access to http://------------------------------xml.aspx" is not allowed etc

The following would match all of the URLs you listed in the previous post:

 

<access uri="http://ytv.com" subdomains="true" />
<access uri="http://img.live.yupptv.com" subdomains="true" />
<access uri="http://edge.static.cdn.yupptv.tv" subdomains="true" />
<access uri="http://www.webmobiads.com" subdomains="true" />
<access uri="http://code.jquery.com" subdomains="true" />

 

However, there is a bit of uncertainty. You mentioned ytv.com which I'm assuming is short for www.ytv.com.

 

You then have code.jquery.com which, if I'm not mistaken, is the full URL, not a short-form, correct? If so, you can shorten it to just jquery.com and it will get the www.jquery.comcode.jquery.com, and all variations of that.

 

Similar for the other URLs. Example, www.webmobiads.com can be shortened to webmobiads.com assuming that there isn't actually anything else before the www.

 

Unfortunately, you can't group yupptv.com. If you did, it *would* white-list live.yupptv.com and cdn.yupptv.com, but since there are additional prefix-domains, they don't share a common URL you can white-list to gain access to both.

 

 

So you don't need *all* of the URLs you noted, they can be grouped together, but you do need to specify every unique domain and, with subdomains="true" minimize the number of entries you need.


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.
Highlighted
New Developer
Posts: 39
Registered: ‎01-10-2014
My Device: BlackBerry Q5
My Carrier: BlackBerry

Re: Unable to parse xml.aspx in my html5 app Error"JavaScript Alert Access to http://------------------------------xml.aspx" is not allowed etc

Thank You but I thought there  may be a simple term   like

 

<access uri="http://mydomains.com" subdomains="true" />



which avoids mentioning all my urls etc everytime.