Current location: Hot Scripts Forums » General Web Coding » JavaScript » Image resize 'onClick' and 'changeIt()'

Image resize 'onClick' and 'changeIt()'

Reply
  #1  
Old 05-01-09, 09:07 PM
bluedogsb bluedogsb is offline
Newbie Coder
 
Join Date: Jan 2009
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Image resize 'onClick' and 'changeIt()'

I'm trying to make it so when you click on this image, it will be larger:

Code:
<div>
				<script type="text/javascript">

				  function changeIt()
				  {
				  var width=640
				  var height=460

				  document.image.width=width
				  document.image.height=height
				  }

				</script>
			 
			<img src="Images/1600psDWG.gif" class="box1" name="image" align="" width="230" height="150" onclick="changeIt()"/>
</div>
The code doesn't execute. I have trouble trying to get javascript to execute for some reason whenever I try to use it.

If there is an easier way to do this function, please let me know.

Thanks in advance,
Blue
Reply With Quote
  #2  
Old 06-23-09, 11:57 AM
jdoejdoe jdoejdoe is offline
New Member
 
Join Date: Jun 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
It works fine in FF and IE7. Make sure your path to the image file is correct.
Reply With Quote
  #3  
Old 06-23-09, 12:12 PM
Nico's Avatar
Nico Nico is online now
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 7,536
Thanks: 5
Thanked 20 Times in 18 Posts
Code:
onclick="changeIt(this)"
... and:
Code:
function changeIt(obj)
{
    obj.width = 640;
    obj.height = 460;
}
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:20 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 (Unregistered)