The new MVC template which came with VS 2012 contains the line of JavaScript below in “_LoginPartial.cshtml”. I have a question about this JavaScript syntax. Is this JavaScript or Asp.Net specific syntax? Can we use JavaScript calls in normal HTML?
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
You can use
<a href="javascript:foo();">..</a>in normal html markup – it’s not Asp.Net specific – but I don’t think it’s regarded as very good unobtrusive js. See the discussion here: How to call javascript function instead of href in HTML where the accepted answer from @Dutchie432 includes this better form:There is also some more discussion of alternatives here: http://www.pageresource.com/jscript/jlinktut.htm