0 Favourites

How do I change an url in the template file dynamically

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

  • Construct 3

    Buy Construct 3

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

    Buy 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)
Similar Topics Posts Views Last Post
Unread hot topic
152 19,230
Magistross's avatar
Magistross
Unread hot topic Locked topic
195 16,196
Ashley's avatar
Ashley Construct Team Founder
Unread hot topic
99 10,136
karshinkoff's avatar
karshinkoff