faqts : Computers : Programming : Languages : JavaScript : Forms : image buttons

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

111 of 149 people (74%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Why is my onclick handler for the INPUT TYPE="IMAGE" button not fired?
what is "javascript: void 0"?

May 17th, 2000 07:27
Martin Honnen, myra gilbert,


NN2/3/4 (and likely IE3) don't support 
  onclick
for 
  INPUT TYPE="image"
elements. As a workaround you can use a link with an image contained 
that is instead of
  <INPUT TYPE="image" SRC="whatever.gif"
         ONCLICK="if (...) 
                    return true;
                  else
                    return false;
                  "
  >
you use
  <A HREF="javascript: void 0"
     ONCLICK="if (...)
                document.formName.submit();
              return false;
             "
  ><IMG SRC="whatever.gif" BORDER="0"></A>