4

I've created a JavaScript web browser game. The HTML page, Game.html, within folder Game references several other JS/jQuery/CSS files stored in sub folders.

I simply want to add the Game folder, which includes the Game.html file and all of its related files to SharePoint 2013 as a page. That way people can play the game on SP 2013.

enter image description here

I've tried the following:

  • Clicked Add Page. This gives me the Master Page and only allows me to add web parts. So I tried adding a Content Editor Web Part and tried to reference the Game.html page, but then I can't reference the rest of the needed JavaScript.

  • Then I mapped my drive directly to the server and uploaded my Game folder to the server. From there, I created a Master Page of Game.html in Design Manager... this did not work.

Is there a simple way to add my Game.html page to SP 2013 and have it reference all of its required JS files and actually run the game?

Thanks


Edit: Okay, here's what I did:

1) I uploaded all assets to http://server/SiteAssets/Forms/AllItems.aspx, including main Game.html file, and supporting images and JS files.

2) Changed all references in Game.html to match the same folder that Game is in:

    <script src="http://Server/SiteAssets/createjs.js"></script>
    <script src="http://Server/SiteAssets/bootstrap.js"></script>
    <script src="http://Server/SiteAssets/jquery.js"></script>
etc...

3) Went to Settings -> Add a page, which is now at http://Server/Pages/Game.aspx.

4) Added Content Editor Web Part (CEWP) to new Page, titled Game. Edited the CEWP to get the Game.html file located in SiteAssets.

5) Game.html seems to render okay:

enter image description here

However, when I submit my name in the text box, it's supposed to run the JavaScript game. But it's not working. I know it's running JavaScript because I did:

Game.html: <body onload="test()">

Game.html: function test() { alert("working"); } Outputs "working".

There's no console output error. And the jQuery and rest of the code seems to render for a second, flicker, and then return to the static HTML...

  • So initially the HTML text field and button from Game.html are loaded: enter image description here

  • When I type my name in and press enter... it calls init(), and loads jquery/createJS,etc enter image description here

  • But then a second later all that disappears and only shows static HTML from Game.html enter image description here

Any thoughts?

user3871
  • 12,432
  • 33
  • 128
  • 268

1 Answers1

0

We've had all sorts of issues with running our own apps within Sharepoint pages.

In the end we went for an entirely different approach. We simply set the app up as an independent site on the same server and then included it into the sharepoint page as a web part. (Essentially an iframe).

It's definitely worth checking out as it entirely removes the associated headaches of sharepoint intercepting requests and the like.

mattl
  • 2,082
  • 3
  • 17
  • 24