Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Introducing JavaScript Finishing the Game Wrapping It Up

Angelic Sanoy
seal-mask
.a{fill-rule:evenodd;}techdegree
Angelic Sanoy
Full Stack JavaScript Techdegree Student 6,743 Points

I downloaded the Introducing Javascript project. When I open the index.html. Nothing works. Any idea?

I downloaded the Introducing Javascript project. When I open the index.html. Nothing works. Any idea?

2 Answers

So if you load up the page, and open up the console, you'll probably see an error similar to below:

Uncaught DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': 
The image element contains cross-origin data, and may not be loaded.

There's an entire world of Cross Origin Resource Sharing (CORS) - but that's definitely out of score for this course!

To get the code up and running, the easiest way is to run it locally on your machine. This sounds like it would take a lot of effort, but can be done in a matter of seconds using python's SimpleHTTPServer.

To do this:

  • Launch a terminal window.
  • Switch to the directory containing the files you wish to run locally
    (e.g cd ~/Desktop/introducing_javascript/bonus_game)
  • Then run the following command:
    python -m SimpleHTTPServer 8000
  • Open up your browser and navigate to http://localhost:8000/ and the everything should be running!

Hope this helps!

Regards
Berian

Angelic Sanoy
seal-mask
.a{fill-rule:evenodd;}techdegree
Angelic Sanoy
Full Stack JavaScript Techdegree Student 6,743 Points

Yes. I just use a cdn to remove the error and warnings but it index.html is still not working. Should I revert back the phaser.js? What do you think is the best approach after running the code above?

How can I make sure this works in all audience if I upload this in a live site?

Btw, thank u so much!

Ahh that's because Python hasn't been added the Windows PATH. I'm on Mac, so python kind of just works here.


If you've already installed Python 2.7 then you need to follow these instructions:

  1. Open System Properties (Right click Computer in the start menu, or use the keyboard shortcut Win+Pause)
  2. Click Advanced system settings in the sidebar.
  3. Click Environment Variables...
  4. Select PATH in the System variables section
  5. Click Edit
  6. Add Python's path to the end of the list (the paths are separated by semicolons). For example: C:\Windows;C:\Windows\System32;C:\Python27

If you have installed Python 3, the installation should have included an option to add python.exe to the system search path. The SimpleHTTPServer python command is slightly different on py3 however,
python -m http.server

Hope this helps!