spgice S
spgice S

Reputation: 29

google chrome error with JavaScript?

i'm trying to put the image in the canvas and this happens...

"Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap)'"

...in Chrome.

var c = document.getElementById("start");
var ctx = c.getContext("2d");
var img = document.getElementById("kid");
ctx.drawImage(img,10,10);
<html>
<head>
<title>beta</title>
</body>
<link href="chip.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<canvas height="938" width="1890" id="start"></canvas>
<script src="beta.js"></script>
<img src="chio.jpg"id="kid"/>
</html> 

html and css works fine. JavaScript the problem.

Upvotes: 1

Views: 138

Answers (1)

The problem is the weird semicolon that you have in the img tag.

Replace

<img src="chio.jpg";id="kid"/>

with

<img src="chio.jpg" id="kid"/>

Upvotes: 2

Related Questions