2 Replies - 624 Views - Last Post: 07 April 2009 - 02:58 PM

#1 steveca  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-May 07

Simple Javascript question on making an image act as button

Post icon  Posted 06 April 2009 - 05:05 AM

hi everyone. I have a button that works great in my javascript. I want to change it from a button to a picture. The button code is:

 <INPUT onmousedown="warning1()" onmouseup="challenger()" type="button" value="Human" name="B1" style="font-size: 10px"> 


When I click on the button it performs the function challenger if this is permitted by warning1.

Hope you are still with me... If the function warning1 does not allow challenger to happen it will display an alert box

How can I change from the button to the image named person.jpeg??? thanks a lot

Is This A Good Question/Topic? 0
  • +

Replies To: Simple Javascript question on making an image act as button

#2 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Simple Javascript question on making an image act as button

Posted 06 April 2009 - 06:57 AM

Best cross browser way is to use an <A> tag that handles the JS and wraps an <IMG> tag
Was This Post Helpful? 0
  • +
  • -

#3 noyesa  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 27
  • Joined: 01-April 09

Re: Simple Javascript question on making an image act as button

Posted 07 April 2009 - 02:58 PM

View Postxerxes333, on 6 Apr, 2009 - 05:57 AM, said:

Best cross browser way is to use an <A> tag that handles the JS and wraps an <IMG> tag

Agreed. If you wrap an image in an <a> tag, the image becomes a link. You can then use events, or if you want to get tricky, event handlers, to attach your Javascript events to the object using the DOM.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1