IE offline
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Strict // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml" xmlns: v = "urn: schemas-microsoft-com: vml">
<Head>
<Meta http-equiv = "content-type" content = "text/html; charset = UTF-8"/>
<Style type = "text/css">
V/: * {behavior: url (# default # VML );}
</Style>
</Head>
<Body>
<V: line
From = '000000'
To = '000000'
Style = 'position: absolute; z-index: 8'>
</V: line>
</Body>
</Html>
<Script>
Var R = function (){};
R. prototype. createLine = function (startX, startY, endX, endY ){
Var le = document. createElement ("<v: line> ");
Le. from = startX + ',' + startY;
Le. to = endX + ',' + endY;
Le. strokecolor = "red ";
Le. strokeweight = "1pt ";
Return le;
}
Var d = new R ();
Document. body. appendChild (d. createLine (1, 200,100 ));
</Script>
FF offline
Copy codeThe Code is as follows:
<Html>
<Head>
<Title> A canvas fillRect, strokeRect and clearRect example </title>
<Meta name = "DC. creator" content = "Kamiel Martinet, http://www.martinet.nl/">
<Meta name = "DC. publisher" content = "Mozilla Developer Center, http://developer.mozilla.org">
<Script type = "text/javascript">
Function drawShape (){
// Get the canvas element using the DOM
Var canvas = document. getElementById ('utorial ');
// Make sure we don't execute when canvas isn't supported
If (canvas. getContext ){
// Use getContext to use the canvas for drawing
Var ctx = canvas. getContext ('2d ');
// Draw shapes
Ctx. fillRect (100,100 );
Ctx. clearRect (45, 45, 60, 60 );
Ctx. strokeRect (50, 50, 50 );
Ctx. beginPath ();
Ctx. moveTo (100,100 );
Ctx. lineTo (200,250 );
Ctx. lineTo (50,250 );
Ctx. closePath ();
Ctx. stroke ();
} Else {
Alert ('You need Safari or Firefox 1.5 + to see this demo .');
}
}
</Script>
<Style type = "text/css">
</Style>
</Head>
<Body onload = "drawShape ();">
<Div>
<Canvas id = "tutorial" width = "400" height = "400"> </canvas>
</Div>
</Body>
</Html>