<! Doctype html public "- // w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <éread> <méta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" /> <itle> nontled 1 </Title> <style type = "text / css"> .style1 {font-size: x-small; } </ style> <script type = "text / javaScript"> / ** points de dessin * / fonction makedot (x, y) {PointDiv = "<div style = 'height: 1px; position: absolue; Left:" + x + "px; top:" + y + "px; width: 1px; background: # f00; overflow: Hidden'> </ divth;;; return PointDiv;} / ** tracez une ligne droite en fonction des coordonnées des deux points. * / Fonction Line (x1, y1, x2, y2) {var pente; // Direction de la pente var; // Motion des coordonnées var tx = x2 - x1; var ty = y2 - y1; if (tx == 0 && ty == 0) return; var Points = ""; var axe; // coordonne sur l'axe if (math.abs (tx)> = math.abs (ty)) {// move direction = tx> 0? 1: -1; tx = math.abs (tx); pente = ty / tx; axe = x1; pour (i = 0; i <tx; i ++) {Points + = makedot (axe, y1 + i * pente); axe + = direction; }} else {// Déplacer la direction sur la direction de l'axe y = Ty> 0? 1: -1; ty = math.abs (ty); pente = tx / ty; axe = y1; pour (i = 0; i <ty; i ++) {points + = makedot (x1 + i * pente, axe); axe + = direction; }} var conteneur = document.getElementById ("conteneur"); contener.innerhtml + = points; } var oldpoint = null; // Obtenez la fonction de la fonction de position de la souris (ev) {ev = ev || window.event; if (ev.pagex || ev.pagey) {return {x: ev.pagex, y: ev.pagey}; } var doc = document.DocumentElement, body = document.body; var pagex = event.clientx + (doc && doc.scrollleft || body && body.scrollleft || 0) - (doc && doc.clientleft || body && body.clientleft || 0); var pagey = event.clienty + (doc && doc.scrolltop || body && body.scrolltop || 0) - (doc && doc.clienttop || body && body.clienttop || 0); return {x: pagex, y: pagey};} fonction RecordPoint (ev) {var point = mousposition (ev); if (oldpoint! = null) {line (oldpoint.x, oldpoint.y, point.x, point.y); } oldpoint = point;} </ script> </ head> <body> <div id = "conteneur" onClick = "RecordPoint (événement);"> </ div> <script type = "text / javascript"> // line (19,19,22,300); </cript> </ body> </html>