Click here to Skip to main content
15,886,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an anchor tag as below ... I want to use anchor onclick event instead of href tag (which is a common practice)
JavaScript
<a href="Javasscript:void(0);"  önclick="javascript:showCandidates()"><%#Eval("TotalAssignedExams")%></a> 


Above code only works fine in Chorme and DOES NOT WORKS IN MOZILLA, IE, OPERA and SAFARI browser.

Upon clicking the link it opens child popup as desire but parent popup navigates to "javasscript:void%280%29;" and gives message on browser "The address wasn't understood"

Tried such alternative on GOOGLE, but it all points to using Javasscript:void(0);in href.

Thanks in advance...
Posted
Updated 29-Mar-18 2:01am
Comments
Member 13197013 12-May-17 16:15pm    
sir my userID palash1,my pin is invaild please give me my pin.

1 solution

If your JavaScript returns false it will cancel the default behavior of the anchor element.

HTML
<a href="#" onclick="showCandidates()">Candidates</a>

JavaScript
function showCandidates()
{
  // code goes here
  return false;
}


(Why don't use input element?)
 
Share this answer
 
Comments
sam7one 2-Jan-14 7:11am    
Thanks it worked...
Not using input element because I have to show count of total candidates and upon clicking that count will show detailed report for candidates...
Member 13197013 12-May-17 16:34pm    
Sir,please give me my pin
Member 13197013 12-May-17 16:26pm    
sir my user ID Palash1,my pin is invaild please give my pin.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900