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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alter Image width and height

Status
Not open for further replies.

ChrisQuick

Programmer
Oct 4, 1999
144
US
I have a page that contains a few photos. I want the photos to be different sizes based on the users screen resolution. The code I have now works fine in IE, but doesn't seem to work in NS. Any ideas how to make it work?

I am defining the images like this in the page:
Code:
<CENTER>
<IMG NAME=&quot;conference2&quot; SRC=&quot;images/spacer1.gif&quot; ALT=&quot;&quot; width=&quot;190&quot; height=&quot;127&quot;><BR>
<IMG SRC=&quot;images/spacer1.gif&quot; ALT=&quot;&quot; WIDTH=&quot;190&quot; HEIGHT=&quot;5&quot;><BR>
<IMG NAME=&quot;conference3&quot; SRC=&quot;images/spacer1.gif&quot; ALT=&quot;&quot; width=&quot;190&quot; height=&quot;127&quot;><BR>
<IMG SRC=&quot;images/spacer1.gif&quot; ALT=&quot;&quot; WIDTH=&quot;190&quot; HEIGHT=&quot;5&quot;><BR>
<IMG NAME=&quot;conference4&quot; SRC=&quot;images/spacer1.gif&quot; ALT=&quot;&quot; width=&quot;190&quot; height=&quot;127&quot;><BR>
</CENTER>

and triggering a javascript function in the body OnLoad event to change the source and dimensions. This is my code:

Code:
<SCRIPT TYPE=&quot;text/javascript&quot; language=&quot;JavaScript&quot;>
	function loadConferencePics(){
		if (document.images) {
			var winWidth = screen.width;
			var winHeight = screen.height;
			if ((winWidth == 800) && (winHeight == 600)){
				document.images.conference2.src = &quot;images/getConf2_500.jpg&quot;;
				document.images.conference2.width = 330;
				document.images.conference2.height = 220;
				document.images.conference3.src = &quot;images/getConf3_500.jpg&quot;;
				document.images.conference3.width = 330;
				document.images.conference3.height = 220;
				document.images.conference4.src = &quot;images/getConf4_500.jpg&quot;;
				document.images.conference4.width = 330;
				document.images.conference4.height = 220;
			}
			
			if ((winWidth > 800) && (winHeight > 600)){
				document.images.conference2.src = &quot;images/getConf2_640.jpg&quot;;
				document.images.conference2.width = 420;
				document.images.conference2.height = 280;
				document.images.conference3.src = &quot;images/getConf3_640.jpg&quot;;
				document.images.conference3.width = 420;
				document.images.conference3.height = 280;
				document.images.conference4.src = &quot;images/getConf4_640.jpg&quot;;
				document.images.conference4.width = 420;
				document.images.conference4.height = 280;	
			}			
		}
	}
	</SCRIPT>
cquick@geotg.com
Geographic Information System (GIS), ASP, some Oracle
 
I'm trying to remember an old project of mine so bear with me, I'll try to find my old project and if what I post now is wrong I'll return later..Anyway..

I think I got round it by using layer tags and having a BACKGROUND set to an image and then resizing the layer. I think I found that I couldn't manipulate the image in an IMG tag so I had to use the layer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top