How do I change an url in the template file dynamically

0 favourites
  • 1 posts
From the Asset Store
Source code, art assets and music tracks to remake this game
  • 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="'+ 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 = '//'+ document.title +'/c2runtime.js';

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


    <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:


    $(document).ready(function() {

    $('script#runtimeUrl').attr('src', '//'+ document.title +'/c2runtime.js');



    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)