项目代码如下:
<div id="register" >
<p>没有注册? <a onclick="regist();"><button >注册</button></a></p>
</div>
function regist(){
//获取当前项目
//var path = "/" + location.pathname.split("/")[1];
if($("#loginType").val()=="用户"){
//跳转到用户注册
//alert(window.location.href);
window.location.href="customerRegist.html";
//window.event.returnValue=false;
//setTimeout("javascript:location.href='customerRegist.html'", 500);
}else if($("#loginType").val()=="员工"){
//跳转到员工注册
//alert("11111");
window.location.href="employeeRegist.html";
//window.event.returnValue=false;
}
解决办法
通过window.enent.returnValue=false;
作用:当捕捉到事件(event)时,判断为false,阻止当前时间继续运行的作用;放在超链接中则不执行超链接;
return false
作用:不是阻止事件继续向顶层元素传播,而是阻止浏览器对事件的默认处理