تصف هذه المقالة طريقة توسيع الصور وتقليلها بواسطة JS. شاركه للرجوع إليه ، على النحو التالي:
var divid ؛ var v_left ؛ var v_top ؛ window.onload = function () {divid = document.getElementById ("block1") ؛ var height1 = images1.hight ؛ // ارتفاع الصورة var width1 = images1.width ؛ // عرض الصورة v_left = (document.body.clientwidth-width1)/2 ؛ v_top = (document.body.clientheight-height1) /2؛divid.style.left=v_left ؛ document.style.top=v_top ؛} drag = 0 ؛ move = 0 ؛ 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" - x) + "px" ؛ return false ؛}} // drag method function initdrag (e) {var odraghandle = nn6؟ E.Target: event.srcelement ؛ var topelement = "html" ؛ بينما (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 = nn6؟ e.clienty: event.clienty ؛ ntx = parseint (odragobj.style.left + 0) ؛ x = nn6؟ e.clientx: event.clientx ؛ document.onmousemove = movemouse ؛ // document.onmouseup = mup ؛ // سيحدث الحدث عند إصدار زر الماوس ؛}} document.onmousedown = initdrag ؛ document.onmouseup = new function ("isDrag = false") ؛ parseint (dragobj.style.top) + 100 ؛} else {if (s == "down") {dragobj.style.top = parseint (dragobj.style.top) - 100 ؛} آخر {if (s == "left") "right") {dragobj.style.left = parseint (dragobj.style.left) - 100 ؛}}}}} // تقليص وظيفة متعددة smallit () {// serink image ، romost spot 1 = images1.height ؛ width1 = width1.width ؛ image1.hight = quight1/1.1 ؛ 1.1 ؛} // Zoom Function Bigit () {/*// Zoom Image ، دون فقدان SPOT Var Zoom = parseint (Images1.Style.zoom ، 10) || 100 ؛ Zoom += event.wheeldelta/ 12 ؛ if (Zoom> 0) {images1.style.zoom = (Zoom +10) +"٪" ؛} * /// Zoom in وفقدت نقطة الساخنة Hight1 = Image1.Height ؛ width1 = Images1.width ؛ Images1.hight = height1 * ؛ {images1.Style.zoom = 100+"٪" ؛ pictures1.hight = pictucts2. = height1 / height2 ؛ var w = width1 / width2 ؛ if (height1 <height2 && width1 <width2) {images1.height = height1 ؛ images1.width = width1 ؛ الارتفاع 1 * width2/width1 ؛}} block1.style.left = 0 ؛ block1.style.top = 0 ؛ document.documentElement.scrolltop ؛} آخر {eleleft = document.body.scrollleft ؛ eletop = document.body.scrolltop ؛} v_left+= eleleft ؛ v_top+= eletop ؛ // divid.style.left = v_left ؛ // divid.style.top = v_top ؛ alert (document.documentElement.scrolltop+ Parseint (O.Style.Zoom ، 10) || 100 ؛ Zoom + = event.wheeldelta / 12 ؛ if (Zoom> 0) {o.style.zoom = Zoom + "٪" ؛} return false ؛}لمزيد من المعلومات حول المحتوى المتعلق بـ JavaScript ، يرجى مراجعة موضوعات هذا الموقع: "JavaScript تبديل المؤثرات الخاصة والتقنيات ملخص" ، "JavaScript الرسوم المتحركة المؤثرات والتقنيات ملخص" ، "JavaScript Search Graftms Marchsms" ، Technique Summary ". ملخص "،" أخطاء JavaScript وملخص لمهارات التصحيح "و" JavaScript Mathematical Operation Summary "
آمل أن تكون هذه المقالة مفيدة لبرمجة JavaScript للجميع.