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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Developer
Shwarup
Posts: 93
Registered: ‎08-18-2011
My Carrier: At&T

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
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 869
Registered: ‎04-12-2010
My Carrier: Bell

Re: Basic XMLHttpRequest sample requesting a CSV

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

Erik Oros
BlackBerry Development Advisor
@WaterlooErik
Please use plain text.
Developer
Shwarup
Posts: 93
Registered: ‎08-18-2011
My Carrier: At&T

Re: Basic XMLHttpRequest sample requesting a CSV

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

Thanks,

Shwarup Biswas
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 869
Registered: ‎04-12-2010
My Carrier: Bell

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
BlackBerry Development Advisor
@WaterlooErik
Please use plain text.