Static URL - Possible?

0 favourites
  • 5 posts
  • Hi Guys,

    As I understand it at the moment c2runtime.js takes the current url to link to the resources, images/media/logo.png and so on, which is great for about 99.6% of use cases <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> . However, not so good for websites using templeting systems or CMS's.

    I am trying to upload a game to a WordPress site (a lot more painful than it should be), if I load all the exported files in the WP root directory and use the code from the game index.html file <body> in the home page, I can get the game to work perfectly. But lets be honest, most of the time that's not where we want the game. Because the url is relevant to the files location If I the create a page in WP called Games the url becomes, so c2runtime.js now trying to find a folder in the root directory called games, which obviously doesn't exist. Creating a folder called games and trying to trick it doesn't work either.

    I know I can embed the games using iframes and other methods but that doesn't fully work for what I'm trying to do.

    Is there a way, in c2runtime.js, to declare a static url to the resource folder, ignoring the what the browser says? or to register/enqueue relevant files in the WP functions file?

    Thanks in advance

  • As far as I know and have experienced, doesn't matter where you placed your resources, if the link point to the index and you haven't moved any other file inside the game structure, it should work fine as intended.

    For example, in the past I used to share my games using dropbox and never had problem with linking it. These days I'm sharing them by some websites, where I created a subfolder and placed the game there, using a shortcut ( to link them, like your link structure, but I can link directly with no problem (, because the system will always ask for the files using the same address of the index.html

    Hope it helped.

  • Hi TELLES0808,

    Thanks for replying. In a normal website you would be right, a typical structure may be:

    Root Folder ¬

    js folder

    css folder

    img folder

    game folder



    and so on, and as long as you point the src in any page to the game folder everything will work fine.

    However, WP doesn't work that way, in fact it doesn't even create pages as such, just meta data in the database used to build a page. Although a url may say the page doesn't physically exist in the directory.

    A usual practice when including scripts in WP is to use a function to register/enqueue the paths to the files so that WP knows where to look, unfortunately I'm not having much luck with it, that's why I was wondering if there was a way to bypass the way c2runtime.js grabs the url and replace it with a static one.


  • Can't you just upload it to a subfolder somewhere and then just point an iframe at it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi Ashley,

    Thanks for the reply. Yes, I can manage that without much of a problem, however, my use case requires that a user plays a game, on the the game over page there is a button to link to a 'my score' page and isn't allowed to go back to the game. This is handled with php $SESSION with a token. Unfortunately, the iframe doesn't end the session, so users can just hit the browser back button to go back to the game, even though I'm using sandbox="allow-same-origin allow-top-navigation" in my iframe. Basically, the ifram isn't letting go.

    I suppose I could add some javascript to my 'my scores' page to check where the request originated and end the session that way. I just thought it would be a more elegant solution to include the game scripts within the WP environment.


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