• ildomandatore

    (@ildomandatore)


    I have inserted this code into the HTML;

    <div style="width:640px;height:480px;max-width:100%">
      <div id="game"></div>
    </div>
    <script type="text/javascript">
        EJS_player = '#game';
        EJS_biosUrl = ''; // Url to Famicom Disk System bios
        EJS_gameUrl = 'https://www.emulatorjs.com/roms/mega_mountain.nes'; // Url to Game rom
        EJS_gameID = 1; // ID in your website, required for netplay.
        EJS_core = 'nes';
        EJS_lightgun = false; // Lightgun
    </script>
    <script src="https://www.emulatorjs.com/loader.js"></script>

    On Tryit the code works, on my site it doesn’t. I tried with Elementor and then with Gutenberg. No way. Where is the problem?

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Vijay Hardaha

    (@vijayhardaha)

    Remove your custom script from the head tag first then remove the post content.

    then in Gutenberg use Custom HTML block and then put your custom HTML there.

    this is not the best way but this should work. if you’ll paste the HTML in post content it’s not gonna work.
    also, remove the comments from your js code. in HTML minify it will give issues.

    Thread Starter ildomandatore

    (@ildomandatore)

    I have done this multiple times. I use Elementor, but I also tested with Gutenberg, deactivating plugins and changing the theme. By any chance WordPress blocks the code like it happened with SVGs?

    Vijay Hardaha

    (@vijayhardaha)

    I have checked your web page, you’re not using the code in a proper way. properly add the code as I explained above and your problem will be solved.

    WordPress doesn’t block any js code, The problem is with your implementation.

    Thread Starter ildomandatore

    (@ildomandatore)

    I rolled the dice several times to guess how to implement a JS … I don’t know how to do it and nobody explains it to me. (or it doesn’t work!), because I always fail. Why go to Gutenberg if I use Elementor? Just to show I’m right? Ok, I’ll give it a try and you’ll see it won’t work.

    Tell me, do you see it? I don’t …
    https://oldfreegame.com/en/uncategorized/5653/

    Vijay Hardaha

    (@vijayhardaha)

    I can see it working now
    https://ibb.co/Dk9swJZ

    but you still need to remove this code from the custom script
    https://ibb.co/YWHpS7L

    and Gutenberg is not required to use, you can use elementor as well, it’s your choice.
    The required thing is that you use a custom HTML block/widget to put your custom HTML code. you can’t just put HTML into post content as a text string.

    Thread Starter ildomandatore

    (@ildomandatore)

    I don’t understand why I don’t see it … https://postimg.cc/vgYJRnJj

    I deleted the snippet you highlighted.

    Vijay Hardaha

    (@vijayhardaha)

    Check-in Incognito Mode or force reload the page.

    Thread Starter ildomandatore

    (@ildomandatore)

    https://postimg.cc/r0vFqQqs

    Thread Starter ildomandatore

    (@ildomandatore)

    I asked three people and all three see the game. Why I don’t see it on my site, but it works if I try to run it on Tryit? Compatibility problems with OSX 10.12 and WordPress?

    Vijay Hardaha

    (@vijayhardaha)

    It’s just a cache issue now, I also don’t see the game sometimes but when I force-reload and try in incognito it works fine.

    You better purge the cache from the plugin and from your hosting then start testing.

    I tested the URL in GTMETRIX as well and the game render fine there.

    Thread Starter ildomandatore

    (@ildomandatore)

    I cleared the cache who knows how many times. For me it is an incompatibility problem with old operating systems. I have a Mac OSX 10.12 and it would be absurd that my website would not be compatible with games. On the Tryit site, the game starts, I’m afraid there is something incompatible on my site.

    Would you give me a link to a test site with the game in it …? I wouldn’t be surprised it’s hosting, even if they insist everything is fine …

    Thread Starter ildomandatore

    (@ildomandatore)

    I have updated the PHP and without the Givewp plugin, the game starts. I close the post. Thanks for collaboration.

    Thread Starter ildomandatore

    (@ildomandatore)

    I thought I solved it, but the games don’t work for me. I installed the new version of PHP and disabled the Givewp plugin.

    I don’t know if I have to copy all the code or some parts have to be copied from other parts? Do I need plugins?

    I am trying to add the codes described on this site; https://github.com/ethanaobrien/emulatorjs

    Maybe I didn’t follow all the steps well.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Js code not working on WordPress.’ is closed to new replies.