If Not A Href Javascript Then What [e.g. Mobile Phones]
Solution 1:
It would be best to use an image button for input:
<inputtype="image" src="someimage.gif" alt="Some Image" onclick="yourFunction()" />
Alternatively, you could also use this form of <a>
:
<ahref="javascript:yourFunction()">Some Link</a>
Solution 2:
The gist of the answers to that question isn't that you should never use anchors as sources of events you intend to handle in JavaScript, just that the anchors should be functional if JavaScript is disabled.
If your app won't work at all with JavaScript disabled, then I wouldn't worry about it and would just use the shortest thing, e.g. #
. (Remember to cancel the default action when handling the event, so the page doesn't scroll back to the top.)
But if you can make your app somewhat functional when JavaScript is disabled, that would be even better. Whether that's feasible will depend on your app. For instance, barring other complexities, your "edit this record" link could, with JavaScript disabled, take you to a whole other page for editing the record — but if JavaScript is enabled, you intercept the click and do an in-place edit, that kind of thing.
Post a Comment for "If Not A Href Javascript Then What [e.g. Mobile Phones]"