How do I change an url in the template file dynamically

0 favourites
  • 1 posts
From the Asset Store
Convert multiple Excel files into JSON files and import them into construct3.
  • Hi,

    The case I am trying to crack is the following. We are implementing a change on our website to host all content in the amazon cdn cloud. This means the url (src="c2runtime.js") of the c2runtime.js must change. Changing the url in the template is easy if it would need to point to one location. But in this case we host multiple games on our portal. And I would like to find a sollution that would prevent me from having to change the url manually each time I export.

    The src in the html template would look something like this (i'm trying to set GAMENAME dynamically):

    <script src="s3.amazonaws.com/example.example.com/gamecontent/'+ GAMENAME +'/c2runtime.js"></script>

    So far I have tried finding a way to change the script's src by making it a variable and constructing the link through

    <script type="text/javascript">

    var myURL = '//s3.amazonaws.com/example.example.com/gamecontent/'+ document.title +'/c2runtime.js';

    document.getElementById('runtimeURL').src = myURL;

    </script>

    <script id="runtimeUrl" src=""></script>

    But this gets me nowhere. It doesnt set the src.

    I also tried to set it using jQuery through the following:

    <script>

    $(document).ready(function() {

    $('script#runtimeUrl').attr('src', '//s3.amazonaws.com/example.example.com/gamecontent/'+ document.title +'/c2runtime.js');

    });

    </script>

    But the page needs c2runtime.js before this is run apparently.

    Does anyone have any tips on how I can set the reference to c2runtime.js dynamically?

    Any help is greatly appreciated. If there is information you need that i forgot to include please let me know. Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)