Call JS on page without writing plugin?

Discussion and feedback on Construct 2

Post » Sun Aug 21, 2011 2:59 am

Is there any way to call a JS function that resides on the page from Construct2 without having to write a plugin?
B
2
G
1
Posts: 1
Reputation: 452

Post » Sun Aug 21, 2011 12:51 pm

No, not yet - right now a plugin's the best way to do it, but I was hoping to add a feature to the Browser object in future to do this.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Fri Jan 27, 2012 12:11 pm

[QUOTE=Ashley] No, not yet - right now a plugin's the best way to do it, but I was hoping to add a feature to the Browser object in future to do this.[/QUOTE]
pardon for digging this up, but I was searching for this and it turns out you can actually use the browser object:

Go To Url action:
"javascript:alert('hello world');void(0);"
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Fri Jan 27, 2012 2:05 pm

This is an old thread, since it was posted I think somebody actually made a CallJS plugin.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Sat May 18, 2013 5:37 pm

Yeah, problem is because my normal site host tries to download the index.html instead of running it, I use scirra arcade... Which doesn't support it so I would have to use gotourl. But, I'm not a hater, so good thread!!!
Sorry about the username, old account XD
B
14
S
4
Posts: 69
Reputation: 1,404

Post » Sat May 18, 2013 6:17 pm

You bumped an old thread again, and it's changed yet again since the last post. r130 beta lets you call javascript directly from the built-in Browser object.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Thu Aug 13, 2015 4:49 pm

@Ashley
Hi,

I am unable to monetize my game because here is Java script for ads
I have java script here ==========

<script language="javascript" type="text/javascript">
var _sa = _sa || [];
_sa.push(["initialize","My game Ads ID]);
_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 Construct 2 General

Who is online

Users browsing this forum: Artpunk and 10 guests