execJS and execute javascript in browser plugin

Discussion of tools and resources for game developers

Post » Mon Mar 24, 2014 3:53 pm

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.
B
3
Posts: 2
Reputation: 189

Post » Mon Mar 24, 2014 8:43 pm

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")
B
10
S
2
G
1
Posts: 202
Reputation: 1,545

Post » Tue Mar 25, 2014 9:32 am

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.
B
3
Posts: 2
Reputation: 189

Post » Tue Mar 25, 2014 8:25 pm

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
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Tue Aug 11, 2015 4:35 pm

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 ?
B
8
S
1
Posts: 45
Reputation: 532


Return to Tools and Resources

Who is online

Users browsing this forum: No registered users and 0 guests