Integrate Kongregate’s JavaScript API in HTML5 Game to Submit High Score

Though Kongregate’s API can be directly initialized in the main game’s HTML, the better way is to always create a Kongregate’s Shell which is nothing but another HTML file which you refer for running the game in stead of your default game’s HTML file. The Shell file in turn embeds your game’s default HTML file using an iFrame. Code for Shell HTML can be used from the code snippet below <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”> <html lang=”en” xml:lang=”en” xmlns=”http://www.w3.org/1999/xhtml”> <head> <title>Kongregate Game Shell</title> <!– Load the Kongregate Javascript API –> <script src=’https://cdn1.kongregate.com/javascripts/kongregate_api.js’></script> <!– Give the shell no border/scroll bars and match the Kongregate background color. If your game needs scrollbars, you might need to modify these styles –> <style type=”text/css”> html{border: none; overflow: hidden; background-color: #333;height: 100%;} body{border: none; background-color: #333;margin:0; padding:0;} </style> </head> <body> <script type=”text/javascript”> // Called when the API is finished loading function onLoadCompleted(){[…]