1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. GTA Network forum is now in archive mode.

browser.call problem

Discussion in 'Archive' started by Henky, Apr 12, 2017.

  1. Henky

    Henky New Member

    Messages:
    2
    Likes Received:
    0
    Joined:
    Apr 12, 2017
    hey, got a problem and cant find it :=(
    i try to transmit a string over js to html but its not working
    index.html:
    Code:
    <!doctype html>
    <html>
       <head>
       <meta charset="utf-8">
       <meta name="viewport" content="width=device-width, initial-scale=1">
           <script>
                function testfunction(test) {
                    document.getElementById("testa").innerHTML = " :" + test;
                };
           </script>
       </head>
       <body>
           <div id="test">
               <div class="test">
                    <p id="testa" style="color: white;">Nothing gonna called</p>
               </div>
           </div>
       </body>
    </html>
    
    js
    Code:
    API.onServerEventTrigger.connect(function (eventName, args){
        switch (eventName){
            case 'OpenPlayerMenu':
                var res = API.getScreenResolution();
                PlayerMenu = API.createCefBrowser(res.Width, res.Height);
                API.waitUntilCefBrowserInit(PlayerMenu);
                API.setCefBrowserPosition(PlayerMenu, 0, 0);
                API.loadPageCefBrowser(PlayerMenu, "client/playermenu/index.html");
                API.showCursor(true);
                API.setCanOpenChat(false);
    
                API.sendNotification(args[0]);
                PlayerMenu.call("testfunction", args[0]);
                break;
        }
    });
    
     
  2. VFRZ

    VFRZ Active Member

    Messages:
    65
    Likes Received:
    19
    Joined:
    Dec 29, 2016
    I was having the same problem, and the problem is that your calling the function before CEF has loaded the full page, so he dont find the function.
    The best would be to use this : https://wiki.gtanet.work/index.php?title=waitUntilCefBrowserLoaded (but not working sadly for now, already on bugtracker)
    The best hack i've found (which is a bit shitty) is to add something like (in your html->js) :
    Code:
    $(document).ready(function() { resourceCall("finished") });
    and then you can call the function normally in "finished" function.
     
  3. Henky

    Henky New Member

    Messages:
    2
    Likes Received:
    0
    Joined:
    Apr 12, 2017
    Thanks but i found another way,
    cef opens on button key and if i click a button on cef the function works pretty good
     

Share This Page