onclick 无法 跳转 js

html:
查看

js:
functin doCheck(id){
alert("daole");

  if(id!=0){
       alert("对不起,您没有权限");
       return false;
     }
  alert("daole");
  return true;
  }

点击“查看“的时候,为什么无法跳转到doCheck这个方法?
ps:${u.u_id }有值

[code="java"] functin doCheck(id){
alert("daole");

if(id!=0){
alert("对不起,您没有权限");
return false;
}
alert("daole");
return true;
} [/code]

哥,你的js有语法错误.
functin 写错了

可能你设置了 超链接 所以没执行JS [color=red]href="www.sina.com" [/color]

把'functin'改成'function'就可以正常运行了。

是不是可以先获取的对象,绑定click事件。根据你之前的逻辑判断,要莫无权限,返回false,要莫重载对象的location,进入页面。现在你的代码可读性不强啊,容易造成困惑。

  1. 首先,onclick不需要使用javascript:xxx()的,因为只有href才能用到javascript:xxx()
  2. script的方法都以function定义,而你把function写错了.

这样改就好了,
[code="java"]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


onclick 无法 跳转 js
<br> &lt;!--原(functin doCheck(id){ )--&gt;<br> function doCheck(id) {<br> alert(&quot;daole&quot;);</p> <pre><code> if (id != 0) { alert(&quot;对不起,您没有权限&quot;); return false; } alert(&quot;daole&quot;); return true; } &lt;/script&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;!--原(&lt;a href=&quot;www.sina.com&quot; onclick=&quot;javascript:doCheck(&#39;${u.u_id }&#39;);&quot;&gt;查看&lt;/a&gt; )--&gt; &lt;a href=&quot;www.sina.com&quot; onclick=&quot;return doCheck(&#39;${u.u_id }&#39;);&quot;&gt;查看&lt;/a&gt; &lt;/BODY&gt; </code></pre> <p></HTML><br> [/code]</p>

1.函数名称错误。
2.你的函数有返回值。
调用方法错误。
应该如下:
查看