Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 821705 of <canvas>

  • Revision slug: Web/HTML/Element/canvas
  • Revision title: <canvas>
  • Revision id: 821705
  • Created:
  • Creator: mayOCAD
  • Is current revision? No
  • Comment

Revision Content

 

 

 

< !DOCTYPE html >
  < html >
  < body >

  < canvas id = "myCanvas"
width = "800"
height = "450"
style = "border:1px solid #d3d3d3;" >
  < /canvas>

< function >
blueCircle.addEventListener("click", getClickPosition, false);

function getClickPosition(e) {
  var xPosition = e.clientX;
  var yPosition = e.clientY;

}

< script >

  var myimgobj = document.images["jsbutton"];
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(300, 400, 40, 0, 6 * Math.PI);
ctx.stroke();
ctx.fillStyle = '#AFEEEE';
ctx.fill();
ctx.stroke();
ctx.strokeStyle = "#F0E68C";
ctx.lineWidth = 5;
ctx.stroke();

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.fillRect(100, 100, 400, 40);

ctx.stroke();
ctx.fillStyle = '#AFEEEE';
ctx.fill();
ctx.stroke();
ctx.strokeStyle = "#F0E68C";
ctx.lineWidth = 5;
ctx.stroke();

< /script> 

< p > This example uses the HTML DOM to assign an "onclick"
event to a p element. < /p>

< p id = "demo" > SEND. < /p>

< script >
  document.getElementById("demo").onclick = function() {
    myFunction()
  };

function myFunction() {

  document.getElementById("demo").innerHTML = "SENT TO SERVER!";
}

< /script>

< /body> < /html>

 

 

 

 

 

 

 

 

Revision Source

<h2>&nbsp;</h2>

<h2>&nbsp;</h2>

<h2>&nbsp;</h2>

<p>&lt; !DOCTYPE html &gt;<br />
 &nbsp; &lt; html &gt;<br />
 &nbsp; &lt; body &gt;</p>

<p>&nbsp; &lt; canvas id = "myCanvas"<br />
 width = "800"<br />
 height = "450"<br />
 style = "border:1px solid #d3d3d3;" &gt;<br />
 &nbsp; &lt; /canvas&gt;</p>

<p>&lt; function &gt;<br />
 blueCircle.addEventListener("click", getClickPosition, false);</p>

<p>function getClickPosition(e) {<br />
 &nbsp; var xPosition = e.clientX;<br />
 &nbsp; var yPosition = e.clientY;</p>

<p>}</p>

<p>&lt; script &gt;</p>

<p>&nbsp; var myimgobj = document.images["jsbutton"];<br />
 var c = document.getElementById("myCanvas");<br />
 var ctx = c.getContext("2d");<br />
 ctx.beginPath();<br />
 ctx.arc(300, 400, 40, 0, 6 * Math.PI);<br />
 ctx.stroke();<br />
 ctx.fillStyle = '#AFEEEE';<br />
 ctx.fill();<br />
 ctx.stroke();<br />
 ctx.strokeStyle = "#F0E68C";<br />
 ctx.lineWidth = 5;<br />
 ctx.stroke();</p>

<p>var c = document.getElementById("myCanvas");<br />
 var ctx = c.getContext("2d");<br />
 ctx.beginPath();<br />
 ctx.fillRect(100, 100, 400, 40);</p>

<p>ctx.stroke();<br />
 ctx.fillStyle = '#AFEEEE';<br />
 ctx.fill();<br />
 ctx.stroke();<br />
 ctx.strokeStyle = "#F0E68C";<br />
 ctx.lineWidth = 5;<br />
 ctx.stroke();</p>

<p>&lt; /script&gt;&nbsp;</p>

<p>&lt; p &gt; This example uses the HTML DOM to assign an "onclick"<br />
 event to a p element. &lt; /p&gt;</p>

<p>&lt; p id = "demo" &gt; SEND. &lt; /p&gt;</p>

<p>&lt; script &gt;<br />
 &nbsp; document.getElementById("demo").onclick = function() {<br />
 &nbsp; &nbsp; myFunction()<br />
 &nbsp; };</p>

<p>function myFunction() {</p>

<p>&nbsp; document.getElementById("demo").innerHTML = "SENT TO SERVER!";<br />
 }</p>

<p>&lt; /script&gt;</p>

<p>&lt; /body&gt; &lt; /html&gt;</p>

<h2>&nbsp;</h2>

<h2>&nbsp;</h2>

<h2>&nbsp;</h2>

<h2>&nbsp;</h2>

<h2>&nbsp;</h2>

<h2>&nbsp;</h2>

<h2>&nbsp;</h2>

<h2 id="Summary">&nbsp;</h2>
Revert to this revision