Call JS on page without writing plugin?

  • Is there any way to call a JS function that resides on the page from Construct2 without having to write a plugin?

  • 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.

  • 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.

    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);"

  • This is an old thread, since it was posted I think somebody actually made a CallJS plugin.

  • 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!!!<img src="smileys/smiley20.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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 ?

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