Set focus on iFrame when game loads

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
Custom Loading Icons to Enhance Your Loading Screens
  • If you publish to Kongregate, the game doesn't have focus when the page loads. The user has to click the iFrame to give focus to the game. This is not a good user experience.

    How to make the game get focus when the frame has finished loading?

    Thanks.

  • I don't know if Kongregate would allow it or not, but it is possible to emulate a click event with jquery $.click, also it has $.focus which might work.

    So something like

    $(window).on('load',function(){

    $('iframe').click();

    })

    or

    $(window).on('load', function(){

    $('iframe').focus();

    })

    might work, but i'm just guessing here.

  • Hey Geo,

    What do you mean by focus?

    When I view my game at Kongregate. Apart from the advert that pops up sometime, I don't have to click on the game for it to start or register my 'mouse over' commands.

    I point the url iframe to a privately hosted url (not the Scirra Arcade).

  • Thanks for the jquery tips, I might try them on the next game if it will be an issue; I won't update the existing game as it would be too much overhead to add the jquery code.

    — your game doesn't get focus either, but because it's played with the mouse it's not an issue - it just gets focus on the first mouse click.

    My game was keyboard only and there's some issues with it - users have to click the iframe first before the game gets the keyboard input.

  • We have the same problem on our Arcade - I don't think there's a good way around it, other than to just have a title screen saying "Click to continue". I think most users are used to clicking inside a window to give it focus.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I didn't tried it, but you can have an out-of-view textbox, inside the iframe (but out of the viewport). If that widget has the focus, then the focus is given to the iframe enclosing it.

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