1I believe that you may be trying to use the background image before has complted loading but you can also use these approaches with CSS.
2
3You can use CSS and either define in your style block or dynamically set it in JS.
4
5<style>
6
7#gameCanvas{
8 background-image: url(/images/backGround.jpg);
9 background-size: cover;
10 background-repeat: no-repeat;
11 background-position: center center;
12}
13</style>
14or if prefer in JS:
15
16document.getElementById("gameCanvas").style.background = "url('/images/backGround.jpg')";
17NB - make sure the image is access to the browser. Also check your console for errors if using JS - the JS may be breaking with an error before reaching your code. Also for a working example see HTML5 Canvas background image