JS 代码执行顺序问题,为什么会跳过刷新页面执行下面的代码。第二个alert总是会执行(chrome浏览器)

论坛 期权论坛 脚本     
匿名网站用户   2020-12-20 11:13   11   0
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试1</title>
</head>
<body>
<input id="test_input">
<button id = 'testbtn'onclick="testfunction(1);testfunction2(0);">测试button</button>
<script>
    window.onload= function(){
        document.getElementById('test_input').value = "123";
    }
    function testfunction(e){
        if(e>0){
            location.reload();
            return;
        }else if(e = 0){
        }
        alert("11不应该出现的代码");
        return false;
    }
    function testfunction2(e){
        if(e>0){
            location.reload();
            return;
        }else if(e = 0){
        }
        alert("22不应该出现的代码");
    }
</script>
</body>
</html>
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1136255
帖子:227251
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP