<a href="addAction?pid=<s:property value="#product.pid"/>" onclick="isLogon()">加入购物车</a>
应该是执行了href里面的内容。

解决方案 »

  1.   

    <html>
    <script type="text/javascript">

    </script>
    <body>
    <input type="button" value="跳转" onclick="window.location.href='http://www.baidu.com'"/>
    <a onclick="window.location.href='http://www.baidu.com';void 0" href="#"> 点击这里 </a>
    </body>
    </html>
      

  2.   


    什么意思?
    我的意思就是满足js方法中的条件就执行该方法的网页跳转
    不满足条件就执行a 中 href
      

  3.   

    兄弟看看试试
    <a href="javascript:void(0);" onclick="isLogon('addAction?pid=<s:property value="#product.pid"/>')">加入购物车</a><script type="text/javascript">
    function isLogon(path){
    var name=document.getElementById("name").value;
    if(name==null) //即使设为true 还是一样
    window.location.href="/jsp/log.jsp";
    }else{
    window.location.href=path;
    }
    </script>
      

  4.   

    已经找到方法了,楼上的方法看上去可行
    <a href="addAction?pid=<s:property value="#product.pid"/>" onclick="return isLogon()">加入</a><script type="text/javascript">
    function isLogon(){
    var name=document.getElementById("name").value;
    if(name==null)
    {window.location.href="/ShoppingWeb/jsp/log.jsp";
    return false;}
    else  {return true;}
    }
    </script>