Artikel ini menjelaskan metode memperbesar, mengurangi dan menyeret gambar oleh JS. Bagikan untuk referensi Anda, sebagai berikut:
var divid; var v_left; var v_top; window.onload = function () {divid = document.geteLementById ("block1"); var height1 = gambar1.height; // tinggi gambar var width1 = gambar1.width; // lebar gambar gambar v_left = (document.body.clientwidth-width1)/2; v_top = (document.body.clientheight-height1) /2;divid.style.left=v_left;divid.style.top=v_top; drag = 0; pindahkan = 0; // drag var var ie = document. isDrag = false; var y, x; var odragobj; function movemouse (e) {if (isDrag) {odragobj.style.top = (nn6? nty + e.clienty - y: nty + event.clienty - y) + "px"; odragobj.style.left. - x) + "px"; return false;}} // seret fungsi metode initdrag (e) {var odraghandle = nn6? E.Target: event.srcelement; var topelement = "html"; while (odraghandle.tagname! = topelement && odraghandle.classname! = "dragable") {odraghandle = nn6? odraghandle.parentnode: odraghandle.parentelement;} if (odraghandle.classname == "dragable") {isDrag = true; odragobj = odraghandle; nty = parseint (odragobj.style.top + 0); y = ntn6? E.Clienty: event.clienty; ntx = parseInt (odragobj.style.left + 0); x = nn6? E.ClientX: event.clientx; document.onMouseMove = movemouse; // document.onmouseup = mup; // peristiwa akan terjadi ketika tombol mouse dirilis;}} document.onmousedown = initdrag; document.onmouseUp = function new ("isDrag = false");//pindahkan fungsi clickmove (s) {s = "oP"); // pindahkan fungsi clickmove (s) {s = "oP");//pindahkan fungsi clickMove (s) {s = "oP"); // pindahkan fungsi clickmove (s) {s = "{s =" {iSDrag "); // function function (s) {s) {s) {s) {s) {s) {s) parseInt (dragobj.style.top) + 100;} else {if (s == "down") {dragobj.style.top = parseInt (dragobj.style.top) - 100;} else {if (s == "kiri") {dragobj.style.left = parseint (s == "left") {dragobj.style.left = parseint (drageint (drageT=; "Benar") {dragobj.style.left = parseInt (dragobj.style.left) - 100;}}}}}} // Kecilkan beberapa fungsi smallit () {// Kecilkan gambar, lose hot spot1 = gambar1.height; width1 = images1.width; gambar 1.HEIGHT1 = Images1. 1.1;} // function zoom bigit () {/*// zoom gambar, tanpa kehilangan hot spot var zoom = parseInt (gambar1.style.zoom, 10) || 100; zoom += event.wheeldelta/ 12; if (zoom> 0) {images1.style.zoom = (zoom +10) +"%";} * /// zoom masuk dan kehilangan hotspot tinggi1 = gambar1.Height; width1 = gambar1.width; gambar1.Height = tinggi * 1.1; realsize () {images1.style.zoom = 100+"%"; gambar1.height = gambar2.height; gambar1.width = gambar2.width; divid.style.left = v_left; divid.style.top = v_top; function fitur () {var width1 = gambar = vare. 360; var Height2 = 200; var h = Height1 / Height2; var w = width1 / width2; if (height1 <height2 && width1 <width2) {images1.height = Height1; gambar1.width = width1;} else {if (h> w) {gambar1.Height = height2; {Images1.width = width2; gambar1.height = height1 * width2/width1;}} block1.style.left = 0; block1.style.top = 0;} // roda mouse zoom masuk dan keluar bbimg (o) {/ * var eleleft; var eletop (document (o) {/ * var eleleft; var eletop (document. document.documentelement.scrollleft; eLetop = document.documentelement.scrolltop;} else {eleleft = document.body.scrollleft; eLetop = document.body.scrolltop;} v_left+= eleleft; v_top+= eLetop; // divid.style.left = v_left; // divid.style.top = v_top; waspada (document.documentelement.scrolltop+"----- xxx"+document.bodyscumentElement.scrolltop+"----- xxx"+document.bodys. parseint (o.style.zoom, 10) || 100; zoom + = event.wheeldelta / 12; if (zoom> 0) {o.style.zoom = zoom + "%";} return false;}For more information about JavaScript related content, please check out the topics of this site: "JavaScript switching special effects and techniques summary", "JavaScript animation special effects and techniques summary", "JavaScript search algorithm skills summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and techniques summary", "JavaScript operation skills Ringkasan "," Kesalahan JavaScript dan Ringkasan Keterampilan Debugging "dan" JavaScript Ringkasan Penggunaan Operasi Matematika "
Saya harap artikel ini akan membantu pemrograman JavaScript semua orang.