Help Needed In Javascript + Image + Href
Solution 1:
The reason I set href="#" is to make my cursor turn into hand, other than that it has no use.
You can remove the <a href="#">
and add the cursor: pointer
style to the image:
<img src="logo.gif" style="cursor: pointer;" />
... to turn the cursor into a hand.
On the other hand, it is probably better to follow the guidelines for progressive enhancement, as David suggested in another answer.
Solution 2:
<ahref="#"><imgsrc="http://www.google.com/intl/en_ALL/images/logo.gif"onClick="alert('hi'); return false;"/></a>
you need add return false;
to your onclick events if you don't want to load the link.
Solution 3:
<ahref="#"><imgsrc="http://www.google.com/intl/en_ALL/images/logo.gif"onClick="alert('hi'); return false;"/></a>
return false
prevents the default action from occurring (in this case navigating to "#"), and then navigating back will return you to the previous page, instead of to the current page without "#".
Solution 4:
Follow the pragmatic guidelines for progressive enhancement. In particular: Build on things that work.
Solution 5:
Use this instead: <img src="http://www.google.com/intl/en_ALL/images/logo.gif" onClick="alert('hi')" style="cursor:pointer"/>
Post a Comment for "Help Needed In Javascript + Image + Href"