Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check and change image size before show it

Status
Not open for further replies.

dimsis

Programmer
Aug 6, 2000
76
0
0
GR
How can i check an image's size before displaying it and according to it's image resize it...
What i want to do is:
I have a table, lets say with 300 pixels width.
I want to display an image inside this table but i need to know if it's bigger tha 300pixels width, it must then displayed with a fixed 300pixels and not more...
If it's smaller than 300 pixels, then it can displayed without forcing (changing) it's width to 300pixels...

Thanx in advance,
Dimitris
 
<HTML><HEAD></HEAD><BODY>
<IMG SRC=&quot;next.gif&quot;>
<IMG SRC=&quot;previous.gif&quot;>
<SCRIPT> <!--
for(i=0; i<document.images.length; i++)
if(document.images.src.indexOf(&quot;previous.gif&quot;)>=0
&& document.images.width > 300)
document.images.width=300;
// -->
</SCRIPT>
</BODY></HTML>

The script must be placed at the end of HTML text, or called as an &quot;onLoad&quot; function
 
Sorry for my ignorance The Forum rules.

The Forum softwere has twice omitted the letter &quot;i&quot; in brackets which followed object &quot;document.images&quot; and toggled on italic font
 
<HTML><HEAD></HEAD><BODY>
<IMG SRC=&quot;next.gif&quot;>
<IMG SRC=&quot;previous.gif&quot;>
<SCRIPT> <!--
for(i=0; i<document.images.length; i++)
if(document.images.src.indexOf(&quot;previous.gif&quot;)>=0)
document.images.width=100;
// -->
</SCRIPT>
</BODY></HTML>
 
Thank you for the help my friend!

Dimitris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top