Re: Mix of javascript, image and href
- From: Laurent Bugnion <galasoft-lb@xxxxxxxxxx>
- Date: Wed, 15 Nov 2006 12:54:06 +0100
Hi,
Edwin Knoppert wrote:
I have an asp.net imagebutton with a clickevent.
I have enclosed an anchor around the image and a small text.
If i click the image the event is executed (while the href of the anchor shows in the statusbar)
If the user clicks the image or the text beneat it it should do the same, executing the image asp.net server event.
I can manage this fine using javascript but the href must contain a character to get the mousehand.
I used # but than the window scrolls to top, postback happens and the scroll position remains to top.
You must return false in the event handler to avoid executing the HREF.
Additionally, the best practice is not to use "#" in the HREF but rather a link to a page explaining why this functionality doesn't work without JavaScript, or linking to a basic page showing the same content, but without the additional functionality provided by JavaScript.
Example:
<a href="nojs.html" onclick="myFunction();return false;">
<img src="..." /></a>
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
.
- Follow-Ups:
- Re: Mix of javascript, image and href
- From: Edwin Knoppert
- Re: Mix of javascript, image and href
- References:
- Mix of javascript, image and href
- From: Edwin Knoppert
- Mix of javascript, image and href
- Prev by Date: Re: Static Classes in Web Applications
- Next by Date: Re: Length of digit after decimal point
- Previous by thread: Mix of javascript, image and href
- Next by thread: Re: Mix of javascript, image and href
- Index(es):
Relevant Pages
|