faqts : Computers : Programming : Languages : JavaScript : Images

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

142 of 184 people (77%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

how i can rotate image 90 degree using script?

Aug 30th, 2001 04:05
Juergen Thelen, Rathakrishnan J,


Afaik this only possible with IE5.5+/Win32, using the rotation property 
of the BasicImage object.
The following snippet will rotate the DIV 90 degrees (clockwise):
--- snip ---
<HTML>
 <HEAD>
  <TITLE>Untitled Document</TITLE>
 </HEAD>
 <BODY bgcolor="#FFFFFF" text="#000000">
 <DIV ID="oDiv" STYLE="position:absolute; left:300px;">
  <IMG SRC="whatever.gif">
 </DIV>
 <BUTTON onclick="oDiv.style.filter=
  'progid:DXImageTransform.Microsoft.BasicImage(rotation=1)'">
  Rotate 90 degrees
 </BUTTON> 
 </BODY>
</HTML>
--- snap ---
Note that even text inside the DIV would be rotated as well. 
Furthermore note that the rotation property doesn't change the DIVs 
content physically. This is because the rotation will always be done 
based on the origin content that the DIV had on load (just in case 
you're wondering why the DIV isn't rotated further, when pressing the 
button multiple times... :o)
The rotation property allows these four values:
  rotation =
   0   no rotation 
   1   rotate 90 degrees 
   2   rotate 180 degrees 
   3   rotate 270 degrees 
Hth, Juergen