I have tried to close the webview with the HTML content is loading in the web view, It has a button on its click, I am triggering postMessage close event, and It’s working while I was checking in the web browser, but when tried in the Android Device, It’s stopped working.
HTML PAGE
Close WebView
Close WebView New
Close Test
COCOS Creator script,
this.node.on(‘InterstitialClosed’, () => {
console.log(‘Button clicked in WebView!’);
this.hideInterstitial();
}, this);
// capture the event for close Interstitial.
window.addEventListener('message', (event) => {
if (event.data && event.data.type === 'close') {
console.log("Button Clicked.");
// Trigger a custom event in Cocos Creator
this.node.emit('InterstitialClosed');
}
});
Is there any other way to close the webview by the click on the webview HTML button?
Also want to know, Is this possible to open the links attached inside the HTML content should open on the device browser instead of loading in webview it self?