calljs updated to work with cocoonjs

0 favourites
  • 3 posts
  • for some reason search failed when I tried to find an original calljs plugin, so new thread.

    if you can't get calljs to work on cocoonjs (and probably direct canvas also), open plugin's runtime.js file and edit it around line 49:

    change this:

    this.nameOfExternalScript = this.properties[0];
              this.returnValue= "";
              var myScriptTag=document.createElement('script');
              myScriptTag.setAttribute("type","text/javascript");
              myScriptTag.setAttribute("src", this.nameOfExternalScript);
              
              if (typeof myScriptTag != "undefined")
                   document.getElementsByTagName("head")[0].appendChild(myScriptTag);

    to this:

    if (typeof this.properties[0] != "undefined" && this.properties[0] != "") {
    this.nameOfExternalScript = this.properties[0];
              this.returnValue= "";
              var myScriptTag=document.createElement('script');
              myScriptTag.setAttribute("type","text/javascript");
              myScriptTag.setAttribute("src", this.nameOfExternalScript);
              
              if (typeof myScriptTag != "undefined")
                   document.getElementsByTagName("head")[0].appendChild(myScriptTag);
    }
    

    and it should work, but remember to clear the plugin's Scriptfile property (it must be empty for it to work with cocoonjs). this change should be done in original plugin also to prevent creating empty <script> tag.

    hope I helped anyone :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The original thread for Call Javascript

    Maybe it's worth contacting Joe7 by PM to see if he could implement this in his plugin in some way.

    Is it worth listing this "trick" in the plugins list ?

  • Hey, thanks!

    I just contacted Joe7, so if he implements this change in the original plugin, I don't think there's much sense in listing it in plugins list.

    Cheers

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)