cocos2d-xcocos2d-jscocoscreator

How to open URL in WebView through .js in cocos creator


I want to open any url like this(https://example.com/mPayment/api.php?playerid=name&method=init) in my WebView through script coding not from design view in CocosCreator. I have done this code but its not opening what I am doing wrong,

var url =  "https://example.com/mPayment/api.php?playerid=name&method=init";
        this.webPage._url = url;
        console.log("Webview1111111  ==== ", this.webPage._url);

and on url there is name where I want to pass the player ID. Acutely I want to implement Payment gateway in my cocos creator game.


Solution

  • Works fine:

    this.webView.url = this.editBox.string;
    

    Maybe you forget to bind webView to UI element in the designer.