本文介绍了如何禁用JavaScript中的href链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标记< a href =#>上一个< / a> 1 2 3 4< a href =#>下一步< / a> ,并且在某些情况下,我希望此标记完全禁用。 如何产生链接)

  if(n_index!= n_pages)
a = a +'< li>< a href =#onclick =javascript:paginateAjaxPage('+(n_index + 1)+','+ stype +');>>< / a>< / li>< li>< a href =#onclick =javascript:paginateAjaxPage('+ n_pages +','+ stype +'); >>>< / A>< /立GT;;
else
a = a +'< li>< a style =cursor:pointer; onclick =return false;>>< / a>< / li>< li>< a style =cursor:pointer; onclick =return false>>>< / a>< / li>';
a = a +'< / ul>< / div>';


解决方案

当您不希望用户重定向

 < a href =javascript:void(0)>我是一个无用的连结< / a> 


I have a tag <a href="#"> Previous </a> 1 2 3 4 <a href="#"> Next </a> and in some conditions I want this tag to be completely disabled.

Code from comments (this is how the link is generated)

if (n_index != n_pages)
    a = a+'<li><a href="#" onclick="javascript:paginateAjaxPage('+(n_index+1) +','+stype+');">></a></li><li><a href="#" onclick="javascript:paginateAjaxPage('+n_pages+','+stype+');" >>></a></li>';
else
    a = a+'<li><a style="cursor: pointer;" onclick="return false;">></a></li><li><a style="cursor: pointer;" onclick="return false" >>></a></li>';
a = a+'</ul></div>';
解决方案

Try this when you dont want user to redirect on click

<a href="javascript: void(0)">I am a useless link</a>

这篇关于如何禁用JavaScript中的href链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:59
查看更多