If you change the name of the function to the body of the function, the program will not work properly.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JS - </title>

<style>
* {
    margin: 0px;
    margin: 0px;
}
body {
    background: -sharpdddddd;
}
h1 {
    text-align: center;
    color: -sharp7b7b7b;
    font-size: 30px;
    position: absolute;
    top: 100px;
    left: 50%;
    width: 300px;
    margin-left: -150px;
}
-sharpdiv1 {
    position: relative;
    width: 400px;
    height: 200px;
    margin: 146px auto 0;
    overflow: hidden;
    box-shadow: 0 0 50px -sharp8e8e8e;
    -webkit-box-shadow: 0 0 50px -sharp8e8e8e;
    -moz-box-shadow: 0 0 50px -sharp8e8e8e;
}
-sharpdiv1 a {
    position: absolute;
    color: -sharp8e8e8e;
    text-decoration: none;
    top: 260px;
    display: block;
    border: -sharp8e8e8e 1px solid;
    box-shadow: 0 0 5px -sharp8e8e8e;
    -webkit-box-shadow: 0 0 5px -sharp8e8e8e;
    -moz-box-shadow: 0 0 5px -sharp8e8e8e;
    background: -sharpfff;
 filter: alpha(opacity= 30);
    opacity: 0.3;
    font-size: 14px;
    padding: 3px 5px;
    font-family: arial;
}
-sharpdiv1 a:hover {
 filter: alpha(opacity= 100);
    opacity: 1;
    font-weight: bold;
    font-size: 16px;
}
</style>
<script>
    var bstop=0;
    var speed=1;
    var it;
    function ss() {
    var oDiv = document.getElementById("div1");
    var aA = document.getElementsByTagName("a");
    var i = 0;
    for (i = 0; i < aA.length; iPP) {
        aA[i].pause = 1;
        aA[i].time = null;
        initialize(aA[i]);
        /*
        var iLeft = parseInt(Math.random() * oDiv.offsetWidth);
        var scale = Math.random() * 1 + 1;
        var iTimer = parseInt(Math.random() * 4000);
        obj.pause = 0;

        obj.style.fontSize = 12 * scale + "px";

        if ((iLeft - obj.offsetWidth) > 0) {
            obj.style.left = iLeft - obj.offsetWidth + "px";
        } else {
            obj.style.left = iLeft + "px";
        }
        clearTimeout(obj.time);
        obj.time = setTimeout(function() {
            obj.pause = 1;
        }, iTimer);
        obj.ispeed = Math.ceil(Math.random() * 4) + speed;
        */        
        aA[i].onmouseover = function() {
            this.pause = 0;
        };
        aA[i].onmouseout = function() {
            this.pause = 1;
        };
    }
    it = setInterval(function(){for (i = 0; i < aA.length; iPP) {
        if (aA[i].pause) {
            if (aA[i].offsetTop <= -aA[i].offsetHeight) {
                aA[i].style.top = oDiv.offsetHeight + "px";
                initialize(aA[i]);
            } else {
                aA[i].ispeed = Math.ceil(Math.random() * 4) + speed;
                aA[i].style.top = aA[i].offsetTop - aA[i].ispeed + "px";
            }
        }
    }}, 50);

    function initialize(obj) {
        var iLeft = parseInt(Math.random() * oDiv.offsetWidth);
        var scale = Math.random() * 1 + 1;
        var iTimer = parseInt(Math.random() * 4000);
        obj.pause = 0;
        obj.style.fontSize = 12 * scale + "px";
        if ((iLeft - obj.offsetWidth) > 0) {
            obj.style.left = iLeft - obj.offsetWidth + "px";
        } else {
            obj.style.left = iLeft + "px";
        }
        clearTimeout(obj.time);
        obj.time = setTimeout(function() {
            obj.pause = 1;
        }, iTimer);
        obj.ispeed = Math.ceil(Math.random() * 4) + speed;
    }
}
    function stop() {
        if(bstop==0){
            speed=40;
            bstop=1;
        }
        else{
            speed=1;
            bstop=0;
        }
    }
</script>

</head>
<body onload="ss()">

<div id="div1">
    <div id="div2">
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" >JavaScript</a>
    <a href="-sharp" >LEO</a>
    <a href="-sharp" ></a>
    <a href="-sharp" >web</a>
    <a href="-sharp" >web</a>
    <a href="-sharp" >css3</a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" >html5</a>
    <a href="-sharp" >web</a>
    <a href="-sharp" >jQuery</a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" >JavaScript</a>
    <a href="-sharp" >LEO</a>
    <a href="-sharp" ></a>
    <a href="-sharp" >web</a>
    <a href="-sharp" >web</a>
    <a href="-sharp" >css3</a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" ></a>
    <a href="-sharp" >html5</a>
    <a href="-sharp" >web</a>
    <a href="-sharp" >jQuery</a>
    </div>
</div>
<input type="button" onClick="stop()" value="stop">
</body>
</html>

change initialize (obj) to function body, the program cannot run

Mar.03,2022
Learn about the scope of

variable

Menu