0

http://nygaming20.wixsite.com/retrobolt/game-1

The link above is a very simple html5 game,you'll notice that when you go up or down the page scrolls.This makes playing the game difficult and annoying so I need to find out how to fix it. The game is embed with iframe,here is what I have in my html code-

<iframe src="http://noborder.netlify.com/" width="675" height="540" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>

Here's a dropbox like to the game's html5 code in full.

https://www.dropbox.com/sh/brsxk97efuohs86/AAAUeIuJy_FoTKQDnGUpgL_Wa?dl=0

1 Answers1

0

You need to prevent key presses from triggering the default browser controls, so in your case using

window.addEventListener("keydown", function(e) {
    // space and arrow keys
    if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
        e.preventDefault();
    }
}, false);

should be sufficient to prevent scrolling

Philip Eagles
  • 888
  • 1
  • 9
  • 27
  • I copied and pasted the code you have and it didn't work,sorry I know nothing about html,I made this in a game engine and am editing the code. – Brandon Mccurdy Dec 01 '16 at 16:11
  • Is there a specific place I should put the code?Could you edit in the html code I have in dropbox? – Brandon Mccurdy Dec 01 '16 at 16:13
  • @BrandonMccurdy StackOverflow is meant to be for helping others with coding issues, not creating code for a user. I would suggest, however, that at the very end of the `` of your HTML file that you add in a `` tag with the above code inside. However, it may be that the problem is that you are using an iframe, so Wix is still scrolling, but I have no idea if it is possible to add JavaScript code directly into the Wix page to stop this. – Philip Eagles Dec 03 '16 at 12:25