I am trying to add a background image and my teacher was trying to explain what to do but it still wouldn't work.
<!DOCTYPE html>
<html>
<head>
<style>
background-image: url("https://imgur.com/sJTAxQG");
</style>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>group project</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<audio id="myAudio">
<source src="8d82b5_Star_Wars_Main_Theme_Song.mp3" type="audio/mpeg">
</audio>
<canvas id="myCanvas" width="480" height="320"></canvas>
<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
var background = new Image();
background.onload = function(){
background.src = 'https://imgur.com/sJTAxQG';
ctx.drawImage(background,0,0);
Everytime I try to run it, nothing happens
Via Active questions tagged javascript - Stack Overflow https://ift.tt/pnYMaFs
Comments
Post a Comment