location.reload()更新页面时,还是会执行后面的js代码。前面js都没执行完毕为什么会执行后面的呢?

论坛 期权论坛 脚本     
匿名网站用户   2020-12-20 11:13   18   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);">测试button</button>
<script src="highcharts/highcharts.js"></script>
<script>
    window.onload= function(){
        document.getElementById('test_input').value = "123";
    }

    function testfunction(e){
        if(e>0){
            location.reload();
        }else if(e = 0){

        }
        alert("不应该出现的代码");
    }
</script>
</body>
</html>

遇到一段自己能力暂时还解决不了的问题,此代码中,alert会出现。为什么会有alert弹出呢。猜想是阻塞相关的问题。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

下载期权论坛手机APP