I just found out a bug in CC Creator 2.1 (may also be the same in 2.1.1).
Description: When navigating in WebView, the ‘url’ property of it should also be updated with the current url which the WebView is currently displaying. Now, ‘loaded’ event is called whenever navigation happened, but with the wrong url (it always returns only the initial url).
If you have example code to post to help the team see the issue, please do. We can ask @jare to take a look at this thread to see if your usage is correct and if there is a bug. Thanks for reporting.
we will see, https://cocos2d-x.org is loaded and ‘loaded’ event is called with the webview object as parameter. (then you check the URL of it and it will says “https://cocos2d-x.org”)
now, inside the webview, click on a link. lets say: “Prodcuts”
again, “loaded” event is called again as we went to a new page (which is correct.)
now, the problem is the callback event’s webview object’s url is not updated to the new url or the url we loaded (https://cocos2d-x.org/products), but it still shows the initial one ('https://cocos2d-x.org")
sorry, WebView dose’t supported this, because the src attribute of the iframe object only reflects the initially defined URL and does not change with the change of the address in the iframe.
FYI: it was working in Android using Cocos 3.8 and I am still using it.
But, for new projects, I really don’t want to use old engine.
I just hope, we have backward compatibility while moving forward.
Now, WebView became just to show a web site.
There is NO way we can communicate with the Game back and forth as it used to.
Rather than focusing on game codes…
We are spending a lot time for finding out why things didn’t work and fixing Engine’s errors
or finding out a walk-around.
and sadly, it drained a lot energy.
I just called evaluateJS once the page is loaded. And nothing happened. But, I saw some errors in android logcat when evaluateJS is called. (Understand that for HTML5, we need to cross-origin handling, now talking about Android).
Eg: evaluateJS(“alert(‘hello from cocos’)”)
Then, nothing happened, then the following errors were logged in logcat.
jswrapper: [ERROR] ([REMOVED]/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/auto/jsb_webview_auto.cpp, 296): wrong number of arguments: 0, was expecting 1: zygote64
jswrapper: [ERROR] Failed to invoke js_webview_WebView_evaluateJS, location: [REMOVED]/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/auto/jsb_webview_auto.cpp:299: zygote64