日期:2014-05-18  浏览次数:20719 次

关于js的跳转问题
是这样的

<a href="addAction?pid=<s:property value="#product.pid"/>" onclick="isLogon()">加入购物车</a>

<script type="text/javascript">
function isLogon(){
var name=document.getElementById("name").value;
if(name==null) //即使设为true 还是一样
window.location.href="/jsp/log.jsp";
}
</script>

为什么不跳转到/jsp/log.jsp?还是当前页面?求解

------解决方案--------------------
<a href="addAction?pid=<s:property value="#product.pid"/>" onclick="isLogon()">加入购物车</a>
应该是执行了href里面的内容。
------解决方案--------------------
<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>

------解决方案--------------------
F12 - - 看下有没有什么错误提示
------解决方案--------------------
兄弟看看试试


<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>