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
Developer
Shwarup
Posts: 93
Registered: ‎08-18-2011
My Device: 9550

Re: Basic XMLHttpRequest sample requesting a CSV

I am getting whole login page content from server and used "window.open();" to load it on webview. Now I need "urlChanged" event or some other way to identify when new url is loading on webview.

 

please find my code bellow:

            function ready() {
                var xmlhttp = new XMLHttpRequest();
                    xmlhttp.onreadystatechange = function () {
                         if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                                     childWindow = window.open("data:text/html,"+unescape( encodeURIComponent( xmlhttp.responseText ) ),"_self");     


                    }
                };
                xmlhttp.open("POST",url, true);
                xmlhttp.send(getRequestBody());
            }

 

NOTE: I want to implement setInterval() to handle urlChanged on webview but it is not firing after page is loaded on webview. could you give me an example to achieve it.

 

 

 

Thanks,

Shwarup Biswas
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: Basic XMLHttpRequest sample requesting a CSV

When you say webview, do you mean the native/Cascades component?


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.
Developer
Shwarup
Posts: 93
Registered: ‎08-18-2011
My Device: 9550

Re: Basic XMLHttpRequest sample requesting a CSV

Not native/Cascades component. I am talking about ChildBrowser.

Thanks,

Shwarup Biswas
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: Basic XMLHttpRequest sample requesting a CSV

Ah, that clears it up. So you can't specifically add an event listener, however the samples we use leverage a setInterval that retrieves the current URL and compares it against the desired value periodically. You can see the implementation here:

https://github.com/blackberry/BB10-WebWorks-Samples/blob/master/FaceBook-OAuth-2/js/app.js#L70


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.