I want to use js to write a code to adjust the image size by dragging the mouse (not finished)

Source: Internet
Author: User

< Script Type = " Text/JavaScript " >
// <Input id = "XY"/> <input id = "xy2"/>
// Setsizebydrop ('webchart1 ');
Document. onmousemove = This_mousemove;
VaR Oldcss =   "" ;
Function Setsizebydrop (ID)
{
VaR OBJ = Document. getelementbyid (ID );
// VaR DIV = Document. createelement ('<Div id = "Div' + ID + '"> </div> ');
// OBJ. parentnode. insertbefore (DIV); Div. insertbefore (OBJ );
// Div. style. Height = obj. offsetheight; Div. style. width = obj. offsetwidth;
OBJ. classname =   ' Vframe ' ;
}
// Move mouse event
Function This_mousemove (E) {
VaRE, OBJ;
OBJ=Document. getelementbyid ('Webchart1');
E=Window. Event?Window. Event: E;
Setdivframestyle (E, OBJ, oldcss );
}
// Set object border and cursor Style
Function Setdivframestyle (E1, obj1, oldcss)
{
VaR B = Setcursorstyle (E1, obj1 );
If (B)
{
Oldcss=Obj1.classname;
Obj1.classname= 'Vframe';
}
Else
{
Obj1.classname=Oldcss;
}
}
// Set the cursor Style
Function Setcursorstyle (E2, obj2)
{
Obj2 = Document. getelementbyid ( ' Webchart1 ' );
VaR X, Y, R, B, I, ISL, ISR, ist, ISB;
X = E2.clientx; y = E2.clienty; I =   10 ;
R = Obj2.offsetleft + Obj2.offsetwidth; B = Obj2.offsettop + Obj2.offsetheight;
Ist = Similar (Y, obj2.offsettop, I );
ISB = Similar (Y, B, I );
Isl = Similar (x, obj2.offsetleft, I );
ISR = Similar (x, R, I );
// $ ('Xy2'). value = obj2.offsetleft + "| Upper" + obj2.offsettop + "| right" + R + "| Lower" + B;
// $ ('Xy'). value = x + ":" + Y + obj2.classname;
If (Isl && IST) {Obj2.style. cursor= "NW-resize";Return True;} // Upper left
If (Isl && ISB) {Obj2.style. cursor= "Sw-resize";Return True;}
If (ISR && IST) {Obj2.style. cursor= "Ne-resize";Return True;} // Upper right
If (ISR && ISB) {Obj2.style. cursor= "Se-resize";Return True;}
If (ISL) {Obj2.style. cursor= "E-resize";Return True;}   // Left
If (ISR) {Obj2.style. cursor= "E-resize";Return True;}   // Right
If (IST) {Obj2.style. cursor= "S-resize";Return True;}   // Upper
If (ISB) {Obj2.style. cursor= "S-resize";Return True;}   // Lower
Obj2.style. cursor =   "" ;
Return   False ;
}
// Compare whether the difference between N1 and N2 is within the range of fuzzy I
Function Similar (N1, N2, I)
{
If(Math. Abs (N1-N2)<=I)Return True;
Else Return False;
}
< / SCRIPT>

When you move the cursor over the image border and make the DIV outside the image show the red border, it cannot be displayed. Who can see why? There are other things at hand. Let's look back.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.