I use cc.webview in My App.
I thought whether I acquire a page URL(in cc.webview) loading now.
I implemented the following sources.
First of all ,URL was displayed in「webview_data」.
URL of the default value that I filled in cocoscreator.
However,When I tap Webview page(in CC.webview), and move to the different page, I can’t find new URL in 「webview_data」.
Can I acquire a URL when I move in Webview page?
Is there the solution?
cc.Class({
extends: cc.Component,
properties: {
webview: cc.WebView,
},
start () {
this.webview.node.on('loading', this.callback, this);
},
callback: function (event) {
var webview_data = event;
var seen = [];
var replacer = function(key, value) {
if (value != null && typeof value == "object") {
if (seen.indexOf(value) >= 0) {
return;
}
seen.push(value);
}
return value;
};
console.log(JSON.stringify(webview_data, replacer));
//there is no new URL in webview_data (I can only default pageURL)
},
});