改成如下代码后window.location.href成功跳转:
<script type="text/javascript"> function checkUser() { if(2!=1){ window.location.href="login.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ; window.event.returnValue=false; } } </script> <p class="extra"> <a class="ui blue right floated primary button" onclick="checkUser()" href="bookConfirm?userId=${account.id}&roomNum=${room.roomNum}&stime=${stime }&etime=${etime }" rel="external nofollow" rel="external nofollow" >确认预订</a> </p>
解决方法二
点击事件中 onclick="checkUser()" 变成 onclick="return checkUser();"
并且在 checkUser中 return false;这样的话 a标签的href也不会执行。 这样就能window.location.href顺利跳转。
代码如下:
<script type="text/javascript"> function checkUser() { if(<%=flag%>!=1){ window.location.href="login.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ; return false; } } </script> <p class="extra"> <a class="ui blue right floated primary button" onclick="return checkUser();" href="bookConfirm?userId=${account.id}&roomNum=${room.roomNum}&stime=${stime }&etime=${etime }">确认预订</a> </p>更多相关内容:
-
无相关信息