Search code examples
javascripthtmlservletsdomvisibility

call javascript function from anchor html tag


I need to display message when the user clicks link

How can I implement something where once the user click the hyper link on Page1, a "processing..." message and then as soon as Page2 is ready it forwards to Page2?

It is working for button click which I earlier posted got response implemented successfully.Thanks.

Hidden DOM element containing the message and to make it visible

Same thing I tried to implement for the below HTML code which is using Servlet not sure how to implement

        <a href="<%=request.getContextPath()%>/servlet/VisibilityController?searchType=workSearchDetails&workNo=<%=installAtLocListBean.getWorkNumber()%>&ID=<%= firstLocationNumber %>&sitePosition=<%=pagePosition%>"><%=installAtLocListBean.getWorkNumber()%>onclick="MyFunction();return true;"</a></td>

Is it possible to do as button click? Can you provide an example of how to do it?


Solution

  • You can use either

    <a href="javascript:someFunction()">LINK</a>
    

    or

    <a href="#" onclick="someFunction(); return false;">LINK</a>
    

    or you can check this link. anchor tag onclick function