Talking with html5 javascript and vice versa - playable ads

Hi, I’m building Unity playable-ad using Cocos Creator 3.x.

According to their document, Mraid.js must be used, and also the game must load only after Mraid is ready, and we should also calling the url via Mraid.open(url).

I wonder if there is a method for Cocos Creator 3.x to “talk” with the “native javascript” side ? For example : upon the download button clicked, how to call the javascript Mraid.open(url) ? And how to delay the loading of the game until Mraid.ready() event received ?

P.S : It just like talking with “native” side like that Java, Objective C from JS but what about JS in html5 “native” itself xD … I’ve heard some one mention using the window property and setting window.functionName = {} to even called the javascript alert() function but when I tried it didn’t work as expected ^^.

Thanks.

https://docs.cocos.com/creator/manual/en/advanced-topics/js-java-bridge.html

1 Like

Hi Luke,

I’ve read the topic you posted before but I guess it’s from JS to Java and Java back to JS for android only ? What I’m looking for it calling from TS script to JS script in html5 generated file…

Found out the solution based on guidance of Cocos Evangelist :D.

Can you please share it here Tyrins? I’m in exactly same need.