js兼容性 - 动态删除script标签后 ,定义的函数是否执行

hello.js
function hello(){
    alert('hello');
}

hello.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script id="hello" src="hello.js"></script>
</head>
<body>
</body>
<script>
    hello();
    if (-[1,]) {
        document.getElementById('hello').remove();
    } else {
        document.getElementById('hello').removeNode(true);
    }
    setTimeout(function(){
        hello();
    },1000);
</script>
</html>

会执行: Chrome,firefox,IE 11,Opera

不执行: Safari

暂时仅测试这些

posted on 2016-04-15 23:37  J4s0n  阅读(1607)  评论(0编辑  收藏  举报

导航