By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,739 Members | 1,523 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,739 IT Pros & Developers. It's quick & easy.

i want a simple custom hiliting button...

P: n/a
hi!

I want to have a custom button change appearance when pressed and then
call a function and change back to its original appearance when released.

here's what i have now, which works mostly. "drop" is my handler for the
button, its argument tells me which button was pressed. i have a number
of these buttons and they are organized in a table.

there is a fair amount of superstition here, the result of many tiny
experiments i ended up with this which seems to work best:

<td>

<A HREF="javascript:drop(0)" onMouseDown="document.images[1].src = 'pressed.gif'"
onMouseOver="document.images[1].src = 'notpressed.gif'"
onMouseOut="document.images[1].src = 'notpressed.gif'"
onMouseUp="document.images[1].src = 'notpressed.gif'">

<IMG SRC="notpressed.gif" HEIGHT= "50" WIDTH= "50" ALIGN= "center" BORDER=0></a>

</td>
pressed.gif is the pressed button's appearance, likewise notpressed.gif
is the normal appearance.

i say this mostly works. there is something i am missing, because the
first press of the first button on a freshly loaded page is weird. and
it is different in different browsers.

in a newer Netscape, the first press first shows no button, then shows
the hilite button and then, when i release the button, it goes to
notpressed.gif. subsequently all buttons work perfectly.

in an older Netscape, the first presses don't work at all, it just shows
a dotted outline of the GIF, until i mouse furiously at a button for a
few strokes within a very short period of time. then all buttons
function perfectly.

in a newer IE, the fist press is a bit weird but all subsequent presses
are perfect, except i get a square hilite box around the button.

i would appreciate a push in the right direction.

-- rob
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sounds like a caching issue to me, cache your images onload of the page then
the machine has the images when the user starts clicking.

Hope that helps, good luck.

Stu

PS also having a bunch of links forcing the use is bad for non JS users (i.e
your HREF="javascript:drop(0)" ), this won't work for non JS users.

"robert" <ra*@tiac.net> wrote in message news:3F***************@tiac.net...
hi!

I want to have a custom button change appearance when pressed and then
call a function and change back to its original appearance when released.

here's what i have now, which works mostly. "drop" is my handler for the
button, its argument tells me which button was pressed. i have a number
of these buttons and they are organized in a table.

there is a fair amount of superstition here, the result of many tiny
experiments i ended up with this which seems to work best:

<td>

<A HREF="javascript:drop(0)" onMouseDown="document.images[1].src = 'pressed.gif'" onMouseOver="document.images[1].src = 'notpressed.gif'" onMouseOut="document.images[1].src = 'notpressed.gif'" onMouseUp="document.images[1].src = 'notpressed.gif'">
<IMG SRC="notpressed.gif" HEIGHT= "50" WIDTH= "50" ALIGN= "center" BORDER=0></a>
</td>
pressed.gif is the pressed button's appearance, likewise notpressed.gif
is the normal appearance.

i say this mostly works. there is something i am missing, because the
first press of the first button on a freshly loaded page is weird. and
it is different in different browsers.

in a newer Netscape, the first press first shows no button, then shows
the hilite button and then, when i release the button, it goes to
notpressed.gif. subsequently all buttons work perfectly.

in an older Netscape, the first presses don't work at all, it just shows
a dotted outline of the GIF, until i mouse furiously at a button for a
few strokes within a very short period of time. then all buttons
function perfectly.

in a newer IE, the fist press is a bit weird but all subsequent presses
are perfect, except i get a square hilite box around the button.

i would appreciate a push in the right direction.

-- rob

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.