01-15-2013 09:41 AM
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.
01-15-2013 10:25 PM
When you say webview, do you mean the native/Cascades component?
01-16-2013 08:47 AM
Not native/Cascades component. I am talking about ChildBrowser.
01-16-2013 11:13 AM
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-Sample