function drawimage()
{
var f=document.getElementById("myCanvas");
var cxt1=f.getContext("2d");
var img1=new Image();
img1.src="image.jpg";
cxt1.drawImage(img1,0,0,750,400);
}
<canvas id="myCanvas" width="1125" height="600" style="border:1px solid #c3c3c3;">
</canvas>
<script type="text/javascript">
drawimage().
This is my javascript but when I am running this on browser, only border comes the 1st time and image appears only after refreshing the page. What is the problem with the code?