Jump to content

Does my game page scroll?


Nygaming
 Share

Recommended Posts

Hi, I'm licensing a game, but the publisher tells me that when they press the up or down keys the page scrolls. Here's a link to the game on my website, press the arrow keys and see if it scrolls happens, also if it does, click inside the game window and see if it stops.

I've been told to put this code in the bottom of my index.html file, but it doesn't seem to work.

<script> 

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

 </script>

http://www.retroboltgames.com/copy-of-ihe-mars-attack

Thanks!

Link to comment
Share on other sites

It does scroll, it stops when the game is active. I would say that's expected behavior, but I suppose such script could fix that if desired.

That script doesn't work though, because it's in the index of your game, which is inserted via `iframe`. The `window` is the iframe, not the whole page. You might be able to use `window.parent` but I think that won't work either unless the iframe is loaded from the same domain as the parent.

Basically, the script needs to be included on the retroboltgames html file, not the game's index.html file.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...