execJS and execute javascript in browser plugin

0 favourites
  • 5 posts
From the Asset Store
Firebase: Analytics, Dynamic Links, Remote Config, Performance, Crashlytics on Android, iOS & Web Browser
  • Hi, I found 'execJS' expression and 'execute javascript' action. What is the differences and how could I do it. I have search it in construct 2 manual, I couldn't find it. Thank you.

  • I use execute javascript to execute some code, and execJS for when I need a return value; i.e;

    On start of layout execute Javascript :

    "

    var div = document.createElement('div');

    div.id = 'my_div';

    div.innerHTML = 'some_val';

    document.body.appendChild(div);

    "

    On touched text

    Set text to browser.ExecJS("my_div.innerHTML")

  • I am not really know how to use it. For example, if I write this script in execute Javascript:

    "

    var dmy = new Date();

    var d = dmy.getDate();

    var m = dmy.getMonth()+1;

    var y = dmy.getFullYear();

    "

    Is it possible to return value through ExecJS? If it is possible, how can I achieve this? Thank you.

  • When you type an expression in the chrome console and press enter, you always get some sort of value (often undefined, or the result of some operations), that's what will get automagically returned by ExecJS.

    In the case of the example you gave, undefined should be returned (maybe as a string, I don't remember (: )

    in Noncentz705's case it should return the div DOM object

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi,

    I have java script here ==========

    "<script language=""javascript"" type=""text/javascript"">

    var _sa = _sa || [];

    _sa.push([""initialize"","" ""]);

    _sa.push(['displayAd']);

    (function () {

    var sa = document.createElement('script');

    sa.type = 'text/javascript';

    sa.async = true;

    sa.src = '//ads.appnext.com/ad/source.js';

    var s = document.getElementsByTagName('script')[0];

    s.parentNode.insertBefore(sa, s);

    })();

    </script>"

    I am doing > On start Of layout > Browser > Execute Java Script ( )

    and in that method I am passing above mentioned Java Script .

    But I think my script not execution, Do not know why ?

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